From e8059d4e9e4ada081363978df1ed937c2b782788 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 20 Jan 2014 03:18:22 +0100 Subject: [configuration] Code cleanup --- src/core/lombok/core/LombokConfiguration.java | 2 +- .../core/configuration/ConfigurationApp.java | 2 +- .../core/configuration/ConfigurationKey.java | 27 ++++------------------ .../configuration/StringConfigurationSource.java | 2 +- 4 files changed, 7 insertions(+), 26 deletions(-) (limited to 'src/core') diff --git a/src/core/lombok/core/LombokConfiguration.java b/src/core/lombok/core/LombokConfiguration.java index 690c05ee..f2661a53 100644 --- a/src/core/lombok/core/LombokConfiguration.java +++ b/src/core/lombok/core/LombokConfiguration.java @@ -60,7 +60,7 @@ public class LombokConfiguration { // create a new empty 'cache' to make sure all problems are reported cache.reset(); ConfigurationResolver resolver = new BubblingConfigurationResolver(cache.sourcesForJavaFile(ast.getAbsoluteFileLocation(), reporter)); - for (ConfigurationKey key : ConfigurationKey.registeredKeys()) { + for (ConfigurationKey key : ConfigurationKey.registeredKeys().values()) { Object value = resolver.resolve(key); if (value == null || value instanceof List && ((List)value).isEmpty()) continue; stream.printf("%s: %s\n", key.getKeyName(), value); diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java index 183bbf6d..e7f438d7 100644 --- a/src/core/lombok/core/configuration/ConfigurationApp.java +++ b/src/core/lombok/core/configuration/ConfigurationApp.java @@ -116,7 +116,7 @@ public class ConfigurationApp extends LombokApp { } private void printConfiguration(PrintStream out, boolean verbose) { - for (ConfigurationKey key : ConfigurationKey.registeredKeys()) { + for (ConfigurationKey key : ConfigurationKey.registeredKeys().values()) { String keyName = key.getKeyName(); ConfigurationDataType type = key.getType(); String description = key.getDescription(); diff --git a/src/core/lombok/core/configuration/ConfigurationKey.java b/src/core/lombok/core/configuration/ConfigurationKey.java index cfd63eb3..d46a70b0 100644 --- a/src/core/lombok/core/configuration/ConfigurationKey.java +++ b/src/core/lombok/core/configuration/ConfigurationKey.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Project Lombok Authors. + * Copyright (C) 2013-2014 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,6 @@ package lombok.core.configuration; import java.util.Collections; -import java.util.Iterator; import java.util.Map; import java.util.TreeMap; import java.util.regex.Pattern; @@ -36,7 +35,7 @@ import java.util.regex.Pattern; * */ public abstract class ConfigurationKey { - private static final Pattern VALID_NAMES = Pattern.compile("[\\-_a-zA-Z][\\-\\.\\w]*(?> registeredKeys = new TreeMap>(String.CASE_INSENSITIVE_ORDER); private static Map> copy; @@ -45,11 +44,6 @@ public abstract class ConfigurationKey { private final String description; private final ConfigurationDataType type; - @Deprecated - public ConfigurationKey(String keyName) { - this(keyName, null); - } - public ConfigurationKey(String keyName, String description) { this.keyName = checkName(keyName); @SuppressWarnings("unchecked") @@ -63,7 +57,7 @@ public abstract class ConfigurationKey { return keyName; } - public String getDescription() { + public final String getDescription() { return description; } @@ -85,26 +79,13 @@ public abstract class ConfigurationKey { * Returns a copy of the currently registered keys. */ @SuppressWarnings("unchecked") - public static Map> registeredKeysMap() { + public static Map> registeredKeys() { synchronized (registeredKeys) { if (copy == null) copy = Collections.unmodifiableMap((Map>) registeredKeys.clone()); return copy; } } - - /** - * Returns a copy of the currently registered keys. - */ - public static Iterable> registeredKeys() { - final Map> map = registeredKeysMap(); - return new Iterable>() { - @Override public Iterator> iterator() { - return map.values().iterator(); - } - }; - } - private static void registerKey(String keyName, ConfigurationKey key) { synchronized (registeredKeys) { if (registeredKeys.containsKey(keyName)) throw new IllegalArgumentException("Key '" + keyName + "' already registered"); diff --git a/src/core/lombok/core/configuration/StringConfigurationSource.java b/src/core/lombok/core/configuration/StringConfigurationSource.java index 27887a6e..aad3d0c8 100644 --- a/src/core/lombok/core/configuration/StringConfigurationSource.java +++ b/src/core/lombok/core/configuration/StringConfigurationSource.java @@ -42,7 +42,7 @@ public class StringConfigurationSource implements ConfigurationSource { Map values = new TreeMap(String.CASE_INSENSITIVE_ORDER); - Map> registeredKeys = ConfigurationKey.registeredKeysMap(); + Map> registeredKeys = ConfigurationKey.registeredKeys(); int lineNumber = 0; Matcher lineMatcher = NEWLINE_FINDER.matcher(content); while (lineMatcher.find()) { -- cgit