Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed all warnings by the ConstantNameCheck (#5200)
Signed-off-by: VelinYordanov <velin.iordanov@gmail.com>
  • Loading branch information
VelinYordanov authored and maggu2810 committed Mar 9, 2018
1 parent d857cc7 commit 66e32d4
Show file tree
Hide file tree
Showing 70 changed files with 1,630 additions and 1,630 deletions.
Expand Up @@ -80,7 +80,7 @@
*/
public class ReferenceResolverUtil {

private static final Logger logger = LoggerFactory.getLogger(ReferenceResolverUtil.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceResolverUtil.class);

private ReferenceResolverUtil() {
}
Expand Down Expand Up @@ -218,7 +218,7 @@ private static String resolvePattern(String reference, Map<String, ?> context) {
end = reference.indexOf('}', start + 2);
if (end == -1) {
previous = start;
logger.warn("Couldn't parse referenced key: {}: expected reference syntax-> ${referencedKey}",
LOGGER.warn("Couldn't parse referenced key: {}: expected reference syntax-> ${referencedKey}",
reference.substring(start));
break;
}
Expand All @@ -230,7 +230,7 @@ private static String resolvePattern(String reference, Map<String, ?> context) {
} else {
// remain as it is: value is null
sb.append(reference.substring(start, end + 1));
logger.warn("Cannot find reference for ${ {} } , it will remain the same.", referencedKey);
LOGGER.warn("Cannot find reference for ${ {} } , it will remain the same.", referencedKey);
}
}
sb.append(reference.substring(previous));
Expand Down
Expand Up @@ -92,7 +92,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide

private static final String DISABLED_RULE_STORAGE = "automation_rules_disabled";
private static final String SOURCE = RuleRegistryImpl.class.getSimpleName();
private static final Logger logger = LoggerFactory.getLogger(RuleRegistryImpl.class.getName());
private final Logger logger = LoggerFactory.getLogger(RuleRegistryImpl.class.getName());

private final RuleEngine ruleEngine = new RuleEngine();
private Storage<Boolean> disabledRulesStorage;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class CoreModuleHandlerFactory extends BaseModuleHandlerFactory {

private Logger logger = LoggerFactory.getLogger(CoreModuleHandlerFactory.class);

private static final Collection<String> types = Arrays.asList(ItemCommandTriggerHandler.MODULE_TYPE_ID,
private static final Collection<String> TYPES = Arrays.asList(ItemCommandTriggerHandler.MODULE_TYPE_ID,
ItemStateTriggerHandler.UPDATE_MODULE_TYPE_ID, ItemStateTriggerHandler.CHANGE_MODULE_TYPE_ID,
ItemStateConditionHandler.ITEM_STATE_CONDITION, ItemCommandActionHandler.ITEM_COMMAND_ACTION,
GenericEventTriggerHandler.MODULE_TYPE_ID, ChannelEventTriggerHandler.MODULE_TYPE_ID,
Expand Down Expand Up @@ -79,7 +79,7 @@ protected void unsetRuleRegistry(RuleRegistry ruleRegistry) {

@Override
public Collection<String> getTypes() {
return types;
return TYPES;
}

/**
Expand Down
Expand Up @@ -43,7 +43,7 @@
*
*/
public class ScriptedAutomationManager {
private static final Logger logger = LoggerFactory.getLogger(ScriptedAutomationManager.class);
private final Logger logger = LoggerFactory.getLogger(ScriptedAutomationManager.class);

private RuleSupportRuleRegistryDelegate ruleRegistryDelegate;

Expand Down
Expand Up @@ -39,7 +39,7 @@ public class ScriptModuleHandlerFactory extends BaseModuleHandlerFactory {

private ScriptEngineManager scriptEngineManager;

private static final Collection<String> types = Arrays
private static final Collection<String> TYPES = Arrays
.asList(new String[] { ScriptActionHandler.SCRIPT_ACTION_ID, ScriptConditionHandler.SCRIPT_CONDITION });

@Override
Expand All @@ -49,7 +49,7 @@ public void activate(BundleContext bundleContext) {

@Override
public Collection<String> getTypes() {
return types;
return TYPES;
}

public void setScriptEngineManager(ScriptEngineManager scriptEngineManager) {
Expand Down
Expand Up @@ -40,7 +40,7 @@ public class TimerModuleHandlerFactory extends BaseModuleHandlerFactory {
private Logger logger = LoggerFactory.getLogger(TimerModuleHandlerFactory.class);

public static final String THREADPOOLNAME = "ruletimer";
private static final Collection<String> types = Arrays
private static final Collection<String> TYPES = Arrays
.asList(new String[] { GenericCronTriggerHandler.MODULE_TYPE_ID, TimeOfDayTriggerHandler.MODULE_TYPE_ID,
DayOfWeekConditionHandler.MODULE_TYPE_ID });

Expand All @@ -51,7 +51,7 @@ public void activate(BundleContext bundleContext) {

@Override
public Collection<String> getTypes() {
return types;
return TYPES;
}

@Override
Expand Down
Expand Up @@ -40,15 +40,15 @@ public class SampleHandlerFactory extends BaseModuleHandlerFactory {
public static final String SUPPORTED_ACTION = "SampleAction";
public static final String MODULE_HANDLER_FACTORY_NAME = "[SampleHandlerFactory]";
private Logger logger = LoggerFactory.getLogger(SampleHandlerFactory.class);
private static final Collection<String> types;
private static final Collection<String> TYPES;
private List<TriggerHandler> createdTriggerHandler = new ArrayList<TriggerHandler>(10);

static {
List<String> temp = new ArrayList<String>();
temp.add(SUPPORTED_TRIGGER);
temp.add(SUPPORTED_CONDITION);
temp.add(SUPPORTED_ACTION);
types = Collections.unmodifiableCollection(temp);
TYPES = Collections.unmodifiableCollection(temp);
}

@Override
Expand All @@ -58,7 +58,7 @@ public void activate(BundleContext bc) {

@Override
public Collection<String> getTypes() {
return types;
return TYPES;
}

/**
Expand Down
Expand Up @@ -47,12 +47,12 @@ public class HandlerFactory extends BaseModuleHandlerFactory implements ModuleHa
/**
* This field contains the types that are supported by this factory.
*/
private static final Collection<String> types;
private static final Collection<String> TYPES;

/**
* For error logging if there is a query for a type that is not supported.
*/
private static final Logger logger;
private static final Logger LOGGER;

/**
* This blocks fills the Collection ,which contains the types supported by this factory, with supported types and
Expand All @@ -63,9 +63,9 @@ public class HandlerFactory extends BaseModuleHandlerFactory implements ModuleHa
temp.add(CompareCondition.UID);
temp.add(ConsoleTrigger.UID);
temp.add(ConsolePrintAction.UID);
types = Collections.unmodifiableCollection(temp);
TYPES = Collections.unmodifiableCollection(temp);

logger = LoggerFactory.getLogger(HandlerFactory.class);
LOGGER = LoggerFactory.getLogger(HandlerFactory.class);
}

/**
Expand All @@ -81,7 +81,7 @@ protected ModuleHandler internalCreate(Module module, String ruleUID) {
} else if (ConsoleTrigger.UID.equals(module.getTypeUID())) {
return new ConsoleTrigger((Trigger) module, bundleContext);
} else {
logger.error(MODULE_HANDLER_FACTORY_NAME + "Not supported moduleHandler: {}", module.getTypeUID());
LOGGER.error(MODULE_HANDLER_FACTORY_NAME + "Not supported moduleHandler: {}", module.getTypeUID());
}

return null;
Expand All @@ -93,7 +93,7 @@ protected ModuleHandler internalCreate(Module module, String ruleUID) {
*/
@Override
public Collection<String> getTypes() {
return types;
return TYPES;
}

/**
Expand Down
Expand Up @@ -34,7 +34,7 @@ public class ConfigDescriptionI18nUtil {

private final TranslationProvider i18nProvider;

private static final Pattern delimiter = Pattern.compile("[:=\\s]");
private static final Pattern DELIMITER = Pattern.compile("[:=\\s]");

public ConfigDescriptionI18nUtil(TranslationProvider i18nProvider) {
this.i18nProvider = i18nProvider;
Expand Down Expand Up @@ -93,7 +93,7 @@ private String inferKey(URI configDescriptionURI, String parameterName, String l

private boolean isValidPropertyKey(String key) {
if (key != null) {
return !delimiter.matcher(key).find();
return !DELIMITER.matcher(key).find();
}
return false;
}
Expand Down
Expand Up @@ -28,15 +28,15 @@
*/
public final class NormalizerFactory {

private static final Map<Type, Normalizer> normalizers;
private static final Map<Type, Normalizer> NORMALIZERS;

static {
Map<Type, Normalizer> map = new HashMap<Type, Normalizer>(11);
map.put(Type.BOOLEAN, new BooleanNormalizer());
map.put(Type.TEXT, new TextNormalizer());
map.put(Type.INTEGER, new IntNormalizer());
map.put(Type.DECIMAL, new DecimalNormalizer());
normalizers = Collections.unmodifiableMap(map);
NORMALIZERS = Collections.unmodifiableMap(map);
}

private NormalizerFactory() {
Expand All @@ -55,7 +55,7 @@ public static Normalizer getNormalizer(ConfigDescriptionParameter configDescript
throw new IllegalArgumentException("The config description parameter must not be null.");
}

Normalizer ret = normalizers.get(configDescriptionParameter.getType());
Normalizer ret = NORMALIZERS.get(configDescriptionParameter.getType());

if (configDescriptionParameter.isMultiple()) {
ret = new ListNormalizer(ret);
Expand Down
Expand Up @@ -27,7 +27,7 @@
*/
final class TypeIntrospections {

private static final Map<Type, TypeIntrospection> introspections = new ImmutableMap.Builder<Type, TypeIntrospection>()
private static final Map<Type, TypeIntrospection> INTROSPECTIONS = new ImmutableMap.Builder<Type, TypeIntrospection>()
.put(Type.BOOLEAN, new BooleanIntrospection()).put(Type.TEXT, new StringIntrospection())
.put(Type.INTEGER, new IntegerIntrospection()).put(Type.DECIMAL, new FloatIntrospection()).build();

Expand All @@ -45,7 +45,7 @@ private TypeIntrospections() {
* @throws IllegalArgumentException if no {@link TypeIntrospection} was found for the given type
*/
static TypeIntrospection get(Type type) {
TypeIntrospection typeIntrospection = introspections.get(type);
TypeIntrospection typeIntrospection = INTROSPECTIONS.get(type);
if (typeIntrospection == null) {
throw new IllegalArgumentException("There is no type introspection for type " + type);
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ public final class ConfigStatusInfoEvent extends AbstractEvent {

private final ConfigStatusInfo configStatusInfo;

private static final Gson gson = new Gson();
private static final Gson GSON = new Gson();

/**
* Creates a new {@link ConfigStatusInfoEvent}.
Expand All @@ -37,7 +37,7 @@ public final class ConfigStatusInfoEvent extends AbstractEvent {
* @param configStatusInfo the corresponding configuration status information to be put as payload into the event
*/
public ConfigStatusInfoEvent(String topic, ConfigStatusInfo configStatusInfo) {
super(topic, gson.toJson(configStatusInfo), null);
super(topic, GSON.toJson(configStatusInfo), null);
this.configStatusInfo = configStatusInfo;
}

Expand Down
Expand Up @@ -104,7 +104,7 @@ protected void stopBackgroundDiscovery() {

@Override
protected void startScan() {
scheduler.schedule(new Runnable() {
SCHEDULER.schedule(new Runnable() {
@Override
public void run() {
scan();
Expand Down
Expand Up @@ -57,7 +57,7 @@ public abstract class AbstractDiscoveryService implements DiscoveryService {

private final Logger logger = LoggerFactory.getLogger(AbstractDiscoveryService.class);

protected static final ScheduledExecutorService scheduler = ThreadPoolManager
protected static final ScheduledExecutorService SCHEDULER = ThreadPoolManager
.getScheduledPool(DISCOVERY_THREADPOOL_NAME);

private final Set<DiscoveryListener> discoveryListeners = new CopyOnWriteArraySet<>();
Expand Down Expand Up @@ -201,7 +201,7 @@ public void run() {
}
};

scheduledStop = scheduler.schedule(runnable, getScanTimeout(), TimeUnit.SECONDS);
scheduledStop = SCHEDULER.schedule(runnable, getScanTimeout(), TimeUnit.SECONDS);
}
this.timestampOfLastScan = new Date().getTime();

Expand Down
Expand Up @@ -80,18 +80,18 @@ protected void activate() {
}
}

private static final Random random = new Random();
private static final Random RANDOM = new Random();

private String createRandomColor() {
StringBuilder ret = new StringBuilder("#");
for (int i = 0; i < 3; i++) {
ret.append(COLOR_VALUES[random.nextInt(COLOR_VALUES.length)]);
ret.append(COLOR_VALUES[RANDOM.nextInt(COLOR_VALUES.length)]);
}
return ret.toString();
}

private String createDescription() {
int index = StringUtils.indexOf(LOREM_IPSUM, ' ', random.nextInt(LOREM_IPSUM.length()));
int index = StringUtils.indexOf(LOREM_IPSUM, ' ', RANDOM.nextInt(LOREM_IPSUM.length()));
if (index < 0) {
index = LOREM_IPSUM.length();
}
Expand Down
Expand Up @@ -34,7 +34,7 @@
*/
public class InstanceUUID {

private static final Logger logger = LoggerFactory.getLogger(InstanceUUID.class);
private static final Logger LOGGER = LoggerFactory.getLogger(InstanceUUID.class);

private static final String UUID_FILE_NAME = "uuid";

Expand All @@ -56,16 +56,16 @@ public static synchronized String get() {
} else {
uuid = readFirstLine(file);
if (StringUtils.isNotEmpty(uuid)) {
logger.debug("UUID '{}' has been restored from file '{}'", file.getAbsolutePath(), uuid);
LOGGER.debug("UUID '{}' has been restored from file '{}'", file.getAbsolutePath(), uuid);
} else {
uuid = java.util.UUID.randomUUID().toString();
logger.warn("UUID file '{}' has no content, rewriting it now with '{}'", file.getAbsolutePath(),
LOGGER.warn("UUID file '{}' has no content, rewriting it now with '{}'", file.getAbsolutePath(),
uuid);
writeFile(file, uuid);
}
}
} catch (IOException e) {
logger.error("Failed writing instance uuid file: {}", e.getMessage());
LOGGER.error("Failed writing instance uuid file: {}", e.getMessage());
return null;
}
}
Expand All @@ -86,7 +86,7 @@ private static String readFirstLine(File file) {
try {
lines = IOUtils.readLines(new FileInputStream(file));
} catch (IOException ioe) {
logger.warn("Failed reading the UUID file '{}': {}", file.getAbsolutePath(), ioe.getMessage());
LOGGER.warn("Failed reading the UUID file '{}': {}", file.getAbsolutePath(), ioe.getMessage());
}
return lines != null && lines.size() > 0 ? lines.get(0) : "";
}
Expand Down
Expand Up @@ -43,7 +43,7 @@
*/
@NonNullByDefault
public class ThingFactory {
private static final Logger logger = LoggerFactory.getLogger(ThingFactory.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ThingFactory.class);

/**
* Generates a random Thing UID for the given thingType
Expand Down Expand Up @@ -100,7 +100,7 @@ public static Thing createThing(ThingType thingType, ThingUID thingUID, Configur
if (thingHandlerFactory.supportsThingType(thingTypeUID)) {
Thing thing = thingHandlerFactory.createThing(thingTypeUID, configuration, thingUID, bridgeUID);
if (thing == null) {
logger.error(
LOGGER.error(
"Thing factory ({}) returned null on create thing when it reports to support the thing type ({}).",
thingHandlerFactory.getClass(), thingTypeUID);
} else {
Expand Down
Expand Up @@ -73,7 +73,7 @@ public final class Firmware implements Comparable<Firmware> {
/** The key for the requires a factory reset property. */
public static final String PROPERTY_REQUIRES_FACTORY_RESET = "requiresFactoryReset";

private static final Logger logger = LoggerFactory.getLogger(Firmware.class);
private static final Logger LOGGER = LoggerFactory.getLogger(Firmware.class);

private final FirmwareUID uid;
private final String vendor;
Expand Down Expand Up @@ -231,7 +231,7 @@ public synchronized byte[] getBytes() {
try (DigestInputStream dis = new DigestInputStream(inputStream, md)) {
bytes = IOUtils.toByteArray(dis);
} catch (IOException ioEx) {
logger.error("Cannot read firmware with UID {}.", uid, ioEx);
LOGGER.error("Cannot read firmware with UID {}.", uid, ioEx);
return null;
}

Expand All @@ -250,7 +250,7 @@ public synchronized byte[] getBytes() {
}
}
} catch (NoSuchAlgorithmException e) {
logger.error("Cannot calculate MD5 checksum.", e);
LOGGER.error("Cannot calculate MD5 checksum.", e);
bytes = null;
return null;
}
Expand Down

0 comments on commit 66e32d4

Please sign in to comment.