diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-01-20 00:44:57 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-01-20 00:44:57 +0100 |
commit | 5be1c574d62f2b5328114dcee49dd0f22b54664f (patch) | |
tree | 39a76463544ea667332563c14d42ff388da6fccc | |
parent | a016e623defbb7f920287793ae0f2a770d0994c3 (diff) | |
download | lombok-5be1c574d62f2b5328114dcee49dd0f22b54664f.tar.gz lombok-5be1c574d62f2b5328114dcee49dd0f22b54664f.tar.bz2 lombok-5be1c574d62f2b5328114dcee49dd0f22b54664f.zip |
[configuration] ConfigurationKey now has a description
-rw-r--r-- | src/core/lombok/ConfigurationKeys.java | 2 | ||||
-rw-r--r-- | src/core/lombok/core/configuration/ConfigurationApp.java | 27 | ||||
-rw-r--r-- | src/core/lombok/core/configuration/ConfigurationKey.java | 16 |
3 files changed, 34 insertions, 11 deletions
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 6fd87e25..021ca5e6 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -306,5 +306,5 @@ public class ConfigurationKeys { * * If set to {@code true}, no futher {@code lombok.config} files will be checked. */ - public static final ConfigurationKey<Boolean> STOP_BUBBLING = new ConfigurationKey<Boolean>("stop-bubbling") {}; + public static final ConfigurationKey<Boolean> STOP_BUBBLING = new ConfigurationKey<Boolean>("stop-bubbling", "Tells the configuration system if it should stop looking for other configuration files.") {}; } diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java index 8694af6a..9dc49662 100644 --- a/src/core/lombok/core/configuration/ConfigurationApp.java +++ b/src/core/lombok/core/configuration/ConfigurationApp.java @@ -119,19 +119,32 @@ public class ConfigurationApp extends LombokApp { for (ConfigurationKey<?> key : ConfigurationKey.registeredKeys()) { String keyName = key.getKeyName(); ConfigurationDataType type = key.getType(); + String description = key.getDescription(); + boolean hasDescription = description != null && !description.isEmpty(); if (!verbose) { - out.printf("# %s (%s)\n", keyName, type); + if (hasDescription) { + out.printf("%s: %s\n", keyName, description); + } else { + out.printf("%s\n", keyName); + } continue; } - out.printf("### Key %s type %s\n", keyName, type); - out.printf("#clear %s\n", keyName); + out.printf("##\n## Key : %s\n## Type: %s\n", keyName, type); + if (hasDescription) { + out.printf("##\n## %s\n", description); + } + out.println("##\n## Examples:\n#"); + out.printf("# clear %s\n", keyName); if (type.isList()) { - out.printf("#%s += %s\n", keyName, exampleValue(type)); - out.printf("#%s -= %s\n", keyName, exampleValue(type)); + out.printf("# %s += %s\n", keyName, exampleValue(type)); + out.printf("# %s -= %s\n", keyName, exampleValue(type)); } else { - out.printf("#%s = %s\n", keyName, exampleValue(type)); + out.printf("# %s = %s\n", keyName, exampleValue(type)); } - out.println(); + out.println("#\n"); + } + if (!verbose) { + out.println("\nUse --verbose for more information."); } } diff --git a/src/core/lombok/core/configuration/ConfigurationKey.java b/src/core/lombok/core/configuration/ConfigurationKey.java index c22ec022..cfd63eb3 100644 --- a/src/core/lombok/core/configuration/ConfigurationKey.java +++ b/src/core/lombok/core/configuration/ConfigurationKey.java @@ -32,7 +32,7 @@ import java.util.regex.Pattern; * <p> * The recommended usage is to create a type token: * <pre> - * private static ConfigurationKey<String> KEY = new ConfigurationKey<String>("keyName") {}; + * private static ConfigurationKey<String> KEY = new ConfigurationKey<String>("keyName", "description") {}; * </pre> */ public abstract class ConfigurationKey<T> { @@ -42,14 +42,20 @@ public abstract class ConfigurationKey<T> { private static Map<String, ConfigurationKey<?>> copy; private final String keyName; + 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") ConfigurationDataType type = ConfigurationDataType.toDataType((Class<? extends ConfigurationKey<?>>)getClass()); this.type = type; - + this.description = description; registerKey(keyName, this); } @@ -57,12 +63,16 @@ public abstract class ConfigurationKey<T> { return keyName; } + public String getDescription() { + return description; + } + public final ConfigurationDataType getType() { return type; } @Override public String toString() { - return keyName + " : " + type; + return keyName + " (" + type + "): " + description; } private static String checkName(String keyName) { |