From 5492c1dd9d7052781ae5cab28bf5bcc829ae9c9e Mon Sep 17 00:00:00 2001 From: mmis Date: Fri, 16 Mar 2018 14:42:22 +0000 Subject: Removed checkstyle warnings Removed checkstyle warnings in policy/common/logging Some warnings remain that required renaming of classes and public methods. These will be taken separately Issue-ID: POLICY-695 Change-Id: Id604c66708917de390c556b50f6266f929b09134 Signed-off-by: mmis --- .../common/logging/nsa/impl/SharedContext.java | 45 ++++++------ .../logging/nsa/impl/Slf4jLoggingContext.java | 80 +++++++++------------- 2 files changed, 54 insertions(+), 71 deletions(-) (limited to 'common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl') diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java index 97f61699..e5f5e65b 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/SharedContext.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,32 +27,27 @@ import org.onap.policy.common.logging.nsa.LoggingContext; import org.onap.policy.common.logging.nsa.SharedLoggingContext; /** - * A shared logging context for SLF4J + * A shared logging context for SLF4J. * */ -public class SharedContext extends Slf4jLoggingContext implements SharedLoggingContext -{ - private final HashMap fMap; - - public SharedContext ( LoggingContext base ) - { - super ( base ); - fMap = new HashMap<> (); - } +public class SharedContext extends Slf4jLoggingContext implements SharedLoggingContext { + private final HashMap contextMap; - @Override - public void put ( String key, String value ) - { - super.put ( key, value ); - fMap.put ( key, value ); - } + public SharedContext(LoggingContext base) { + super(base); + contextMap = new HashMap<>(); + } - @Override - public void transferTo ( SharedLoggingContext lc ) - { - for ( Entry e : fMap.entrySet () ) - { - lc.put ( e.getKey(), e.getValue() ); - } - } + @Override + public void put(String key, String value) { + super.put(key, value); + contextMap.put(key, value); + } + + @Override + public void transferTo(SharedLoggingContext lc) { + for (Entry e : contextMap.entrySet()) { + lc.put(e.getKey(), e.getValue()); + } + } } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java index 628d4b9e..80bb2383 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/impl/Slf4jLoggingContext.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,54 +20,42 @@ package org.onap.policy.common.logging.nsa.impl; -import org.slf4j.MDC; - import org.onap.policy.common.logging.nsa.LoggingContext; +import org.slf4j.MDC; /** - * A logging context for SLF4J + * A logging context for SLF4J. * */ -public class Slf4jLoggingContext implements LoggingContext -{ - public Slf4jLoggingContext ( LoggingContext base ) - { - } - - @Override - public void put ( String key, String value ) - { - MDC.put ( key, value ); - } - - @Override - public void put ( String key, long value ) - { - put ( key, Long.toString(value)); - } - - @Override - public String get ( String key, String defaultValue ) - { - String result = MDC.get ( key ); - if ( result == null ) - { - result = defaultValue; - } - return result; - } - - @Override - public long get ( String key, long defaultValue ) - { - final String str = get ( key, Long.toString(defaultValue)); - try - { - return Long.parseLong ( str ); - } - catch ( NumberFormatException x ) - { - return defaultValue; - } - } +public class Slf4jLoggingContext implements LoggingContext { + public Slf4jLoggingContext(LoggingContext base) {} + + @Override + public void put(String key, String value) { + MDC.put(key, value); + } + + @Override + public void put(String key, long value) { + put(key, Long.toString(value)); + } + + @Override + public String get(String key, String defaultValue) { + String result = MDC.get(key); + if (result == null) { + result = defaultValue; + } + return result; + } + + @Override + public long get(String key, long defaultValue) { + final String str = get(key, Long.toString(defaultValue)); + try { + return Long.parseLong(str); + } catch (NumberFormatException x) { + return defaultValue; + } + } } -- cgit 1.2.3-korg