From f258229b88a797694320b1794a4084998411a94b Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 22 Nov 2010 23:52:34 +0100 Subject: - Renamed the diverse @Log annotations to give them distinct names - Removed the option to specify a different class to log on - Updated tests and documentation --- src/core/lombok/eclipse/handlers/HandleLog.java | 50 +++++--------- .../lombok/extern/apachecommons/CommonsLog.java | 57 ++++++++++++++++ src/core/lombok/extern/apachecommons/Log.java | 77 ---------------------- src/core/lombok/extern/java/Log.java | 56 ++++++++++++++++ src/core/lombok/extern/jul/Log.java | 76 --------------------- src/core/lombok/extern/log4j/Log.java | 77 ---------------------- src/core/lombok/extern/log4j/Log4j.java | 57 ++++++++++++++++ src/core/lombok/extern/slf4j/Log.java | 75 --------------------- src/core/lombok/extern/slf4j/Slf4j.java | 55 ++++++++++++++++ src/core/lombok/javac/handlers/HandleLog.java | 49 +++++--------- .../resource/after-delombok/LoggerCommons.java | 8 +-- .../resource/after-delombok/LoggerJul.java | 8 +-- .../resource/after-delombok/LoggerLog4j.java | 8 +-- .../resource/after-delombok/LoggerSlf4j.java | 5 ++ .../after-delombok/LoggerSlf4jClassOfArray.java | 6 -- .../after-delombok/LoggerSlf4jWithClass.java | 12 ---- .../resource/after-ecj/LoggerCommons.java | 17 ++--- test/transform/resource/after-ecj/LoggerJul.java | 17 ++--- test/transform/resource/after-ecj/LoggerLog4j.java | 17 ++--- test/transform/resource/after-ecj/LoggerSlf4j.java | 13 +++- .../after-ecj/LoggerSlf4jAlreadyExists.java | 2 +- .../after-ecj/LoggerSlf4jClassOfArray.java | 16 ----- .../resource/after-ecj/LoggerSlf4jOnNonType.java | 2 +- .../resource/after-ecj/LoggerSlf4jTypes.java | 10 +-- .../resource/after-ecj/LoggerSlf4jWithClass.java | 32 --------- .../resource/after-ecj/LoggerSlf4jWithPackage.java | 4 +- test/transform/resource/before/LoggerCommons.java | 12 ++-- test/transform/resource/before/LoggerJul.java | 12 ++-- test/transform/resource/before/LoggerLog4j.java | 12 ++-- test/transform/resource/before/LoggerSlf4j.java | 11 +++- .../resource/before/LoggerSlf4jAlreadyExists.java | 2 +- .../resource/before/LoggerSlf4jClassOfArray.java | 6 -- .../resource/before/LoggerSlf4jOnNonType.java | 2 +- .../resource/before/LoggerSlf4jTypes.java | 10 +-- .../resource/before/LoggerSlf4jWithClass.java | 12 ---- .../resource/before/LoggerSlf4jWithPackage.java | 4 +- website/features/GetterLazy.html | 2 +- website/features/Log.html | 21 +++--- 38 files changed, 352 insertions(+), 560 deletions(-) create mode 100644 src/core/lombok/extern/apachecommons/CommonsLog.java delete mode 100644 src/core/lombok/extern/apachecommons/Log.java create mode 100644 src/core/lombok/extern/java/Log.java delete mode 100644 src/core/lombok/extern/jul/Log.java delete mode 100644 src/core/lombok/extern/log4j/Log.java create mode 100644 src/core/lombok/extern/log4j/Log4j.java delete mode 100644 src/core/lombok/extern/slf4j/Log.java create mode 100644 src/core/lombok/extern/slf4j/Slf4j.java delete mode 100644 test/transform/resource/after-delombok/LoggerSlf4jClassOfArray.java delete mode 100644 test/transform/resource/after-delombok/LoggerSlf4jWithClass.java delete mode 100644 test/transform/resource/after-ecj/LoggerSlf4jClassOfArray.java delete mode 100644 test/transform/resource/after-ecj/LoggerSlf4jWithClass.java delete mode 100644 test/transform/resource/before/LoggerSlf4jClassOfArray.java delete mode 100644 test/transform/resource/before/LoggerSlf4jWithClass.java diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 1df33e89..be856208 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -52,12 +52,6 @@ public class HandleLog { } public static boolean processAnnotation(LoggingFramework framework, AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { - Expression annotationValue = (Expression) annotation.getActualExpression("value"); - if (annotationValue != null && !(annotationValue instanceof ClassLiteralAccess)) { - return true; - } - ClassLiteralAccess loggingType = (ClassLiteralAccess)annotationValue; - EclipseNode owner = annotationNode.up(); switch (owner.getKind()) { case TYPE: @@ -78,9 +72,7 @@ public class HandleLog { return true; } - if (loggingType == null) { - loggingType = selfType(owner, source); - } + ClassLiteralAccess loggingType = selfType(owner, source); injectField(owner, createField(framework, source, loggingType)); owner.rebuild(); @@ -158,51 +150,51 @@ public class HandleLog { } /** - * Handles the {@link lombok.extern.apachecommons.Log} annotation for Eclipse. + * Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleCommonsLog implements EclipseAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { + public static class HandleCommonsLog implements EclipseAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { return processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode); } } /** - * Handles the {@link lombok.extern.jul.Log} annotation for Eclipse. + * Handles the {@link lombok.extern.java.Log} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleJulLog implements EclipseAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { + public static class HandleJulLog implements EclipseAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { return processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode); } } /** - * Handles the {@link lombok.extern.log4j.Log} annotation for Eclipse. + * Handles the {@link lombok.extern.log4j.Log4j} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleLog4jLog implements EclipseAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { + public static class HandleLog4jLog implements EclipseAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { return processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode); } } /** - * Handles the {@link lombok.extern.slf4j.Log} annotation for Eclipse. + * Handles the {@link lombok.extern.slf4j.Slf4j} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleSlf4jLog implements EclipseAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { + public static class HandleSlf4jLog implements EclipseAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, Annotation source, EclipseNode annotationNode) { return processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode); } } enum LoggingFramework { // private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class); - COMMONS(lombok.extern.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog"), + COMMONS("org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog"), // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName()); - JUL(lombok.extern.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger", "getLogger") { + JUL("java.util.logging.Logger", "java.util.logging.Logger", "getLogger") { @Override public Expression createFactoryParameter(ClassLiteralAccess type, Annotation source) { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -222,29 +214,23 @@ public class HandleLog { }, // private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class); - LOG4J(lombok.extern.jul.Log.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger", "getLogger"), + LOG4J("org.apache.log4j.Logger", "org.apache.log4j.Logger", "getLogger"), // private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class); - SLF4J(lombok.extern.slf4j.Log.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory", "getLogger"), + SLF4J("org.slf4j.Logger", "org.slf4j.LoggerFactory", "getLogger"), ; - private final Class annotationClass; private final String loggerTypeName; private final String loggerFactoryTypeName; private final String loggerFactoryMethodName; - LoggingFramework(Class annotationClass, String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName) { - this.annotationClass = annotationClass; + LoggingFramework(String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName) { this.loggerTypeName = loggerTypeName; this.loggerFactoryTypeName = loggerFactoryTypeName; this.loggerFactoryMethodName = loggerFactoryMethodName; } - final Class getAnnotationClass() { - return annotationClass; - } - final String getLoggerTypeName() { return loggerTypeName; } diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java new file mode 100644 index 00000000..452f97f0 --- /dev/null +++ b/src/core/lombok/extern/apachecommons/CommonsLog.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.extern.apachecommons; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Causes lombok to generate a logger field. + * Example: + *
+ * @CommonsLog
+ * public class LogExample {
+ * }
+ * 
+ * + * will generate: + * + *
+ * public class LogExample {
+ *     private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class);
+ * }
+ * 
+ * + * This annotation is valid for classes and enumerations.
+ * + * @see org.apache.commons.logging.Log org.apache.commons.logging.Log + * @see org.apache.commons.logging.LogFactory#getLog(java.lang.Class) org.apache.commons.logging.LogFactory.getLog(Class target) + * @see lombok.extern.java.Log @Log + * @see lombok.extern.log4j.Log4j @Log4j + * @see lombok.extern.slf4j.Slf4j @Slf4j + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface CommonsLog { +} \ No newline at end of file diff --git a/src/core/lombok/extern/apachecommons/Log.java b/src/core/lombok/extern/apachecommons/Log.java deleted file mode 100644 index 87e7ab2c..00000000 --- a/src/core/lombok/extern/apachecommons/Log.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.extern.apachecommons; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Causes lombok to generate a logger field. - * Example: - *
- * @Log
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class);
- * }
- * 
- * - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class. - * Example: - *
- * @Log(java.util.List.class)
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(java.util.List.class);
- * }
- * 
- * - * This annotation is valid for classes and enumerations.
- * - * @see org.apache.commons.logging.Log org.apache.commons.logging.Log - * @see org.apache.commons.logging.LogFactory#getLog(java.lang.Class) org.apache.commons.logging.LogFactory.getLog(Class target) - * @see lombok.extern.jul.Log lombok.extern.jul.Log - * @see lombok.extern.log4j.Log lombok.extern.log4j.Log - * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Log { - /** - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here. - */ - Class value() default void.class; -} \ No newline at end of file diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java new file mode 100644 index 00000000..e6e01736 --- /dev/null +++ b/src/core/lombok/extern/java/Log.java @@ -0,0 +1,56 @@ +/* + * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.extern.java; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Causes lombok to generate a logger field. + * Example: + *
+ * @Log
+ * public class LogExample {
+ * }
+ * 
+ * + * will generate: + * + *
+ * public class LogExample {
+ *     private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());
+ * }
+ * 
+ * + * This annotation is valid for classes and enumerations.
+ * @see java.util.logging.Logger java.util.logging.Logger + * @see java.util.logging.Logger#getLogger(java.lang.String) java.util.logging.Logger.getLogger(String name) + * @see lombok.extern.apachecommons.CommonsLog @CommonsLog + * @see lombok.extern.log4j.Log4j @Log4j + * @see lombok.extern.slf4j.Slf4j @Slf4j + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface Log { +} \ No newline at end of file diff --git a/src/core/lombok/extern/jul/Log.java b/src/core/lombok/extern/jul/Log.java deleted file mode 100644 index 8b2ec3af..00000000 --- a/src/core/lombok/extern/jul/Log.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.extern.jul; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Causes lombok to generate a logger field. - * Example: - *
- * @Log
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());
- * }
- * 
- * - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class. - * Example: - *
- * @Log(java.util.List.class)
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.util.List.class.getName());
- * }
- * 
- * - * This annotation is valid for classes and enumerations.
- * @see java.util.logging.Logger java.util.logging.Logger - * @see java.util.logging.Logger#getLogger(java.lang.String) java.util.logging.Logger.getLogger(String name) - * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log - * @see lombok.extern.log4j.Log lombok.extern.log4j.Log - * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Log { - /** - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here. - */ - Class value() default void.class; -} \ No newline at end of file diff --git a/src/core/lombok/extern/log4j/Log.java b/src/core/lombok/extern/log4j/Log.java deleted file mode 100644 index 9d07f46d..00000000 --- a/src/core/lombok/extern/log4j/Log.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.extern.log4j; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Causes lombok to generate a logger field. - * Example: - *
- * @Log
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LogExample.class);
- * }
- * 
- * - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class. - * Example: - *
- * @Log(java.util.List.class)
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(java.util.List.class);
- * }
- * 
- * - * This annotation is valid for classes and enumerations.
- * - * @see org.apache.log4j.Logger org.apache.log4j.Logger - * @see org.apache.log4j.Logger#getLogger(java.lang.Class) org.apache.log4j.Logger.getLogger(Class target) - * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log - * @see lombok.extern.jul.Log lombok.extern.jul.Log - * @see lombok.extern.slf4j.Log lombok.extern.slf4j.Log - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Log { - /** - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here. - */ - Class value() default void.class; -} \ No newline at end of file diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java new file mode 100644 index 00000000..eeaf80be --- /dev/null +++ b/src/core/lombok/extern/log4j/Log4j.java @@ -0,0 +1,57 @@ +/* + * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.extern.log4j; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Causes lombok to generate a logger field. + * Example: + *
+ * @Log4j
+ * public class LogExample {
+ * }
+ * 
+ * + * will generate: + * + *
+ * public class LogExample {
+ *     private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LogExample.class);
+ * }
+ * 
+ * + * This annotation is valid for classes and enumerations.
+ * + * @see org.apache.log4j.Logger org.apache.log4j.Logger + * @see org.apache.log4j.Logger#getLogger(java.lang.Class) org.apache.log4j.Logger.getLogger(Class target) + * @see lombok.extern.apachecommons.CommonsLog @CommonsLog + * @see lombok.extern.java.Log @Log + * @see lombok.extern.slf4j.Slf4j @Slf4j + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface Log4j { +} \ No newline at end of file diff --git a/src/core/lombok/extern/slf4j/Log.java b/src/core/lombok/extern/slf4j/Log.java deleted file mode 100644 index 63307008..00000000 --- a/src/core/lombok/extern/slf4j/Log.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.extern.slf4j; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -/** - * Causes lombok to generate a logger field. - * Example: - *
- * @Log
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);
- * }
- * 
- * - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class. - * Example: - *
- * @Log(java.util.List.class)
- * public class LogExample {
- * }
- * 
- * - * will generate: - * - *
- * public class LogExample {
- *     private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.util.List.class); 
- * }
- * 
- * - * This annotation is valid for classes and enumerations.
- * @see org.slf4j.Logger org.slf4j.Logger - * @see org.slf4j.LoggerFactory#getLogger(java.lang.Class) org.slf4j.LoggerFactory.getLogger(Class target) - * @see lombok.extern.apachecommons.Log lombok.extern.apachecommons.Log - * @see lombok.extern.jul.Log lombok.extern.jul.Log - * @see lombok.extern.log4j.Log lombok.extern.log4j.Log - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Log { - /** - * If you do not want to use the annotated class as the logger parameter, you can specify an alternate class here. - */ - Class value() default void.class; -} diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java new file mode 100644 index 00000000..4986fd0c --- /dev/null +++ b/src/core/lombok/extern/slf4j/Slf4j.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.extern.slf4j; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +/** + * Causes lombok to generate a logger field. + * Example: + *
+ * @Slf4j
+ * public class LogExample {
+ * }
+ * 
+ * + * will generate: + * + *
+ * public class LogExample {
+ *     private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);
+ * }
+ * 
+ * + * This annotation is valid for classes and enumerations.
+ * @see org.slf4j.Logger org.slf4j.Logger + * @see org.slf4j.LoggerFactory#getLogger(java.lang.Class) org.slf4j.LoggerFactory.getLogger(Class target) + * @see lombok.extern.apachecommons.CommonsLog @CommonsLog + * @see lombok.extern.java.Log @Log + * @see lombok.extern.log4j.Log4j @Log4j + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.TYPE) +public @interface Slf4j { +} diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java index c72892cc..53d327af 100644 --- a/src/core/lombok/javac/handlers/HandleLog.java +++ b/src/core/lombok/javac/handlers/HandleLog.java @@ -52,19 +52,6 @@ public class HandleLog { public static boolean processAnnotation(LoggingFramework framework, AnnotationValues annotation, JavacNode annotationNode) { markAnnotationAsProcessed(annotationNode, framework.getAnnotationClass()); -// String loggingClassName = annotation.getRawExpression("value"); -// if (loggingClassName == null) loggingClassName = "void"; -// if (loggingClassName.endsWith(".class")) loggingClassName = loggingClassName.substring(0, loggingClassName.length() - 6); - - JCExpression annotationValue = (JCExpression) annotation.getActualExpression("value"); - JCFieldAccess loggingType = null; - if (annotationValue != null) { - if (!(annotationValue instanceof JCFieldAccess)) return true; - loggingType = (JCFieldAccess) annotationValue; - if (!loggingType.name.contentEquals("class")) return true; - } - - JavacNode typeNode = annotationNode.up(); switch (typeNode.getKind()) { case TYPE: @@ -78,9 +65,7 @@ public class HandleLog { return true; } - if (loggingType == null) { - loggingType = selfType(typeNode); - } + JCFieldAccess loggingType = selfType(typeNode); createField(framework, typeNode, loggingType); return true; default: @@ -114,11 +99,11 @@ public class HandleLog { } /** - * Handles the {@link lombok.extern.apachecommons.Log} annotation for javac. + * Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) - public static class HandleCommonsLog implements JavacAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + public static class HandleCommonsLog implements JavacAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { return processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode); } @@ -128,11 +113,11 @@ public class HandleLog { } /** - * Handles the {@link lombok.extern.jul.Log} annotation for javac. + * Handles the {@link lombok.extern.java.Log} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) - public static class HandleJulLog implements JavacAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + public static class HandleJulLog implements JavacAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { return processAnnotation(LoggingFramework.JUL, annotation, annotationNode); } @@ -142,11 +127,11 @@ public class HandleLog { } /** - * Handles the {@link lombok.extern.log4j.Log} annotation for javac. + * Handles the {@link lombok.extern.log4j.Log4j} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) - public static class HandleLog4jLog implements JavacAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + public static class HandleLog4jLog implements JavacAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { return processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode); } @@ -156,11 +141,11 @@ public class HandleLog { } /** - * Handles the {@link lombok.extern.slf4j.Log} annotation for javac. + * Handles the {@link lombok.extern.slf4j.Slf4j} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) - public static class HandleSlf4jLog implements JavacAnnotationHandler { - @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + public static class HandleSlf4jLog implements JavacAnnotationHandler { + @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { return processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode); } @@ -171,10 +156,10 @@ public class HandleLog { enum LoggingFramework { // private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class); - COMMONS(lombok.extern.jul.Log.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"), + COMMONS(lombok.extern.apachecommons.CommonsLog.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"), // private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(TargetType.class.getName()); - JUL(lombok.extern.jul.Log.class, "java.util.logging.Logger", "java.util.logging.Logger.getLogger") { + JUL(lombok.extern.java.Log.class, "java.util.logging.Logger", "java.util.logging.Logger.getLogger") { @Override public JCExpression createFactoryParameter(JavacNode typeNode, JCFieldAccess loggingType) { TreeMaker maker = typeNode.getTreeMaker(); JCExpression method = maker.Select(loggingType, typeNode.toName("getName")); @@ -183,10 +168,10 @@ public class HandleLog { }, // private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TargetType.class); - LOG4J(lombok.extern.jul.Log.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger.getLogger"), + LOG4J(lombok.extern.log4j.Log4j.class, "org.apache.log4j.Logger", "org.apache.log4j.Logger.getLogger"), // private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(TargetType.class); - SLF4J(lombok.extern.slf4j.Log.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory.getLogger"), + SLF4J(lombok.extern.slf4j.Slf4j.class, "org.slf4j.Logger", "org.slf4j.LoggerFactory.getLogger"), ; diff --git a/test/transform/resource/after-delombok/LoggerCommons.java b/test/transform/resource/after-delombok/LoggerCommons.java index a55aa336..c2a03815 100644 --- a/test/transform/resource/after-delombok/LoggerCommons.java +++ b/test/transform/resource/after-delombok/LoggerCommons.java @@ -1,9 +1,7 @@ class LoggerCommons { private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommons.class); } -class LoggerCommonsString { - private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(String.class); -} -class LoggerCommonsJavaLangString { - private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(java.lang.String.class); + +class LoggerCommonsWithImport { + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class); } \ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java index 51f19926..39cb2aac 100644 --- a/test/transform/resource/after-delombok/LoggerJul.java +++ b/test/transform/resource/after-delombok/LoggerJul.java @@ -1,9 +1,7 @@ class LoggerJul { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName()); } -class LoggerJulString { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(String.class.getName()); -} -class LoggerJulJavaLangString { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.lang.String.class.getName()); + +class LoggerJulWithImport { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName()); } \ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerLog4j.java b/test/transform/resource/after-delombok/LoggerLog4j.java index e946c858..6892a7d8 100644 --- a/test/transform/resource/after-delombok/LoggerLog4j.java +++ b/test/transform/resource/after-delombok/LoggerLog4j.java @@ -1,9 +1,7 @@ class LoggerLog4j { private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4j.class); } -class LoggerLog4jString { - private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(String.class); -} -class LoggerLog4jJavaLangString { - private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(java.lang.String.class); + +class LoggerLog4jWithImport { + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class); } \ No newline at end of file diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java index c7c84631..cb1486ba 100644 --- a/test/transform/resource/after-delombok/LoggerSlf4j.java +++ b/test/transform/resource/after-delombok/LoggerSlf4j.java @@ -1,6 +1,11 @@ class LoggerSlf4j { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4j.class); } + +class LoggerSlf4jWithImport { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithImport.class); +} + class LoggerSlf4jOuter { static class Inner { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); diff --git a/test/transform/resource/after-delombok/LoggerSlf4jClassOfArray.java b/test/transform/resource/after-delombok/LoggerSlf4jClassOfArray.java deleted file mode 100644 index 00b44d5c..00000000 --- a/test/transform/resource/after-delombok/LoggerSlf4jClassOfArray.java +++ /dev/null @@ -1,6 +0,0 @@ -class LoggerSlf4jClassOfArray { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(String[].class); -} -class LoggerSlf4jClassOfArrayJLS { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.lang.String[].class); -} diff --git a/test/transform/resource/after-delombok/LoggerSlf4jWithClass.java b/test/transform/resource/after-delombok/LoggerSlf4jWithClass.java deleted file mode 100644 index b4e2181e..00000000 --- a/test/transform/resource/after-delombok/LoggerSlf4jWithClass.java +++ /dev/null @@ -1,12 +0,0 @@ -class LoggerSlf4jWithClass { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(String.class); -} -class LoggerSlf4jWithClassList { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.util.List.class); -} -class LoggerSlf4jWithClassValue { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.lang.String.class); -} -class LoggerSlf4jWithClassVoid { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(void.class); -} diff --git a/test/transform/resource/after-ecj/LoggerCommons.java b/test/transform/resource/after-ecj/LoggerCommons.java index bb38983f..d63bb9c1 100644 --- a/test/transform/resource/after-ecj/LoggerCommons.java +++ b/test/transform/resource/after-ecj/LoggerCommons.java @@ -1,4 +1,5 @@ -@lombok.extern.apachecommons.Log class LoggerCommons { +import lombok.extern.apachecommons.CommonsLog; +@lombok.extern.apachecommons.CommonsLog class LoggerCommons { private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommons.class); () { } @@ -6,19 +7,11 @@ super(); } } -@lombok.extern.apachecommons.Log(String.class) class LoggerCommonsString { - private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(String.class); +@CommonsLog class LoggerCommonsWithImport { + private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class); () { } - LoggerCommonsString() { - super(); - } -} -@lombok.extern.apachecommons.Log(java.lang.String.class) class LoggerCommonsJavaLangString { - private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(java.lang.String.class); - () { - } - LoggerCommonsJavaLangString() { + LoggerCommonsWithImport() { super(); } } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java index 3d09cb71..c98dfe27 100644 --- a/test/transform/resource/after-ecj/LoggerJul.java +++ b/test/transform/resource/after-ecj/LoggerJul.java @@ -1,4 +1,5 @@ -@lombok.extern.jul.Log class LoggerJul { +import lombok.extern.java.Log; +@lombok.extern.java.Log class LoggerJul { private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJul.class.getName()); () { } @@ -6,19 +7,11 @@ super(); } } -@lombok.extern.jul.Log(String.class) class LoggerJulString { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(String.class.getName()); +@Log class LoggerJulWithImport { + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName()); () { } - LoggerJulString() { - super(); - } -} -@lombok.extern.jul.Log(java.lang.String.class) class LoggerJulJavaLangString { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(java.lang.String.class.getName()); - () { - } - LoggerJulJavaLangString() { + LoggerJulWithImport() { super(); } } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerLog4j.java b/test/transform/resource/after-ecj/LoggerLog4j.java index 45898a57..6814be7b 100644 --- a/test/transform/resource/after-ecj/LoggerLog4j.java +++ b/test/transform/resource/after-ecj/LoggerLog4j.java @@ -1,4 +1,5 @@ -@lombok.extern.log4j.Log class LoggerLog4j { +import lombok.extern.log4j.Log4j; +@lombok.extern.log4j.Log4j class LoggerLog4j { private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4j.class); () { } @@ -6,19 +7,11 @@ super(); } } -@lombok.extern.log4j.Log(String.class) class LoggerLog4jString { - private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(String.class); +@Log4j class LoggerLog4jWithImport { + private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class); () { } - LoggerLog4jString() { - super(); - } -} -@lombok.extern.log4j.Log(java.lang.String.class) class LoggerLog4jJavaLangString { - private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(java.lang.String.class); - () { - } - LoggerLog4jJavaLangString() { + LoggerLog4jWithImport() { super(); } } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java index e635ece8..1ccf5c9e 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4j.java +++ b/test/transform/resource/after-ecj/LoggerSlf4j.java @@ -1,4 +1,5 @@ -@lombok.extern.slf4j.Log class LoggerSlf4j { +import lombok.extern.slf4j.Slf4j; +@lombok.extern.slf4j.Slf4j class LoggerSlf4j { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4j.class); () { } @@ -6,8 +7,16 @@ super(); } } +@Slf4j class LoggerSlf4jWithImport { + private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithImport.class); + () { + } + LoggerSlf4jWithImport() { + super(); + } +} class LoggerSlf4jOuter { - static @lombok.extern.slf4j.Log class Inner { + static @lombok.extern.slf4j.Slf4j class Inner { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); () { } diff --git a/test/transform/resource/after-ecj/LoggerSlf4jAlreadyExists.java b/test/transform/resource/after-ecj/LoggerSlf4jAlreadyExists.java index 22fa0eeb..5fb6bc06 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4jAlreadyExists.java +++ b/test/transform/resource/after-ecj/LoggerSlf4jAlreadyExists.java @@ -1,4 +1,4 @@ -@lombok.extern.slf4j.Log class LoggerSlf4jAlreadyExists { +@lombok.extern.slf4j.Slf4j class LoggerSlf4jAlreadyExists { int log; LoggerSlf4jAlreadyExists() { super(); diff --git a/test/transform/resource/after-ecj/LoggerSlf4jClassOfArray.java b/test/transform/resource/after-ecj/LoggerSlf4jClassOfArray.java deleted file mode 100644 index 20fe0fde..00000000 --- a/test/transform/resource/after-ecj/LoggerSlf4jClassOfArray.java +++ /dev/null @@ -1,16 +0,0 @@ -@lombok.extern.slf4j.Log(String[].class) class LoggerSlf4jClassOfArray { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(String[].class); - () { - } - LoggerSlf4jClassOfArray() { - super(); - } -} -@lombok.extern.slf4j.Log(java.lang.String[].class) class LoggerSlf4jClassOfArrayJLS { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.lang.String[].class); - () { - } - LoggerSlf4jClassOfArrayJLS() { - super(); - } -} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerSlf4jOnNonType.java b/test/transform/resource/after-ecj/LoggerSlf4jOnNonType.java index a45612ae..f0c2ee58 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4jOnNonType.java +++ b/test/transform/resource/after-ecj/LoggerSlf4jOnNonType.java @@ -2,6 +2,6 @@ class LoggerSlf4jOnNonType { LoggerSlf4jOnNonType() { super(); } - @lombok.extern.slf4j.Log void foo() { + @lombok.extern.slf4j.Slf4j void foo() { } } \ No newline at end of file diff --git a/test/transform/resource/after-ecj/LoggerSlf4jTypes.java b/test/transform/resource/after-ecj/LoggerSlf4jTypes.java index 25b3fd86..95ed1ebf 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4jTypes.java +++ b/test/transform/resource/after-ecj/LoggerSlf4jTypes.java @@ -1,8 +1,8 @@ -@lombok.extern.slf4j.Log interface LoggerSlf4jTypesInterface { +@lombok.extern.slf4j.Slf4j interface LoggerSlf4jTypesInterface { } -@lombok.extern.slf4j.Log @interface LoggerSlf4jTypesAnnotation { +@lombok.extern.slf4j.Slf4j @interface LoggerSlf4jTypesAnnotation { } -@lombok.extern.slf4j.Log enum LoggerSlf4jTypesEnum { +@lombok.extern.slf4j.Slf4j enum LoggerSlf4jTypesEnum { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnum.class); () { } @@ -10,7 +10,7 @@ super(); } } -@lombok.extern.slf4j.Log enum LoggerSlf4jTypesEnumWithElement { +@lombok.extern.slf4j.Slf4j enum LoggerSlf4jTypesEnumWithElement { FOO(), private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jTypesEnumWithElement.class); () { @@ -20,7 +20,7 @@ } } interface LoggerSlf4jTypesInterfaceOuter { - @lombok.extern.slf4j.Log class Inner { + @lombok.extern.slf4j.Slf4j class Inner { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); () { } diff --git a/test/transform/resource/after-ecj/LoggerSlf4jWithClass.java b/test/transform/resource/after-ecj/LoggerSlf4jWithClass.java deleted file mode 100644 index 9f4846aa..00000000 --- a/test/transform/resource/after-ecj/LoggerSlf4jWithClass.java +++ /dev/null @@ -1,32 +0,0 @@ -@lombok.extern.slf4j.Log(String.class) class LoggerSlf4jWithClass { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(String.class); - () { - } - LoggerSlf4jWithClass() { - super(); - } -} -@lombok.extern.slf4j.Log(java.util.List.class) class LoggerSlf4jWithClassList { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.util.List.class); - () { - } - LoggerSlf4jWithClassList() { - super(); - } -} -@lombok.extern.slf4j.Log(value = java.lang.String.class) class LoggerSlf4jWithClassValue { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(java.lang.String.class); - () { - } - LoggerSlf4jWithClassValue() { - super(); - } -} -@lombok.extern.slf4j.Log(void.class) class LoggerSlf4jWithClassVoid { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(void.class); - () { - } - LoggerSlf4jWithClassVoid() { - super(); - } -} diff --git a/test/transform/resource/after-ecj/LoggerSlf4jWithPackage.java b/test/transform/resource/after-ecj/LoggerSlf4jWithPackage.java index 655d14f8..6d395db8 100644 --- a/test/transform/resource/after-ecj/LoggerSlf4jWithPackage.java +++ b/test/transform/resource/after-ecj/LoggerSlf4jWithPackage.java @@ -1,5 +1,5 @@ package before; -@lombok.extern.slf4j.Log class LoggerSlf4jWithPackage { +@lombok.extern.slf4j.Slf4j class LoggerSlf4jWithPackage { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LoggerSlf4jWithPackage.class); () { } @@ -8,7 +8,7 @@ package before; } } class LoggerSlf4jWithPackageOuter { - static @lombok.extern.slf4j.Log class Inner { + static @lombok.extern.slf4j.Slf4j class Inner { private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class); () { } diff --git a/test/transform/resource/before/LoggerCommons.java b/test/transform/resource/before/LoggerCommons.java index d6359bd7..52210d25 100644 --- a/test/transform/resource/before/LoggerCommons.java +++ b/test/transform/resource/before/LoggerCommons.java @@ -1,11 +1,9 @@ -@lombok.extern.apachecommons.Log -class LoggerCommons { -} +import lombok.extern.apachecommons.CommonsLog; -@lombok.extern.apachecommons.Log(String.class) -class LoggerCommonsString { +@lombok.extern.apachecommons.CommonsLog +class LoggerCommons { } -@lombok.extern.apachecommons.Log(java.lang.String.class) -class LoggerCommonsJavaLangString { +@CommonsLog +class LoggerCommonsWithImport { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerJul.java b/test/transform/resource/before/LoggerJul.java index 1c74ea4f..52869e81 100644 --- a/test/transform/resource/before/LoggerJul.java +++ b/test/transform/resource/before/LoggerJul.java @@ -1,11 +1,9 @@ -@lombok.extern.jul.Log -class LoggerJul { -} +import lombok.extern.java.Log; -@lombok.extern.jul.Log(String.class) -class LoggerJulString { +@lombok.extern.java.Log +class LoggerJul { } -@lombok.extern.jul.Log(java.lang.String.class) -class LoggerJulJavaLangString { +@Log +class LoggerJulWithImport { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerLog4j.java b/test/transform/resource/before/LoggerLog4j.java index 0199809c..03735bff 100644 --- a/test/transform/resource/before/LoggerLog4j.java +++ b/test/transform/resource/before/LoggerLog4j.java @@ -1,11 +1,9 @@ -@lombok.extern.log4j.Log -class LoggerLog4j { -} +import lombok.extern.log4j.Log4j; -@lombok.extern.log4j.Log(String.class) -class LoggerLog4jString { +@lombok.extern.log4j.Log4j +class LoggerLog4j { } -@lombok.extern.log4j.Log(java.lang.String.class) -class LoggerLog4jJavaLangString { +@Log4j +class LoggerLog4jWithImport { } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java index 92aeefbd..133ee36e 100644 --- a/test/transform/resource/before/LoggerSlf4j.java +++ b/test/transform/resource/before/LoggerSlf4j.java @@ -1,8 +1,15 @@ -@lombok.extern.slf4j.Log +import lombok.extern.slf4j.Slf4j; + +@lombok.extern.slf4j.Slf4j class LoggerSlf4j { } + +@Slf4j +class LoggerSlf4jWithImport { +} + class LoggerSlf4jOuter { - @lombok.extern.slf4j.Log + @lombok.extern.slf4j.Slf4j static class Inner { } diff --git a/test/transform/resource/before/LoggerSlf4jAlreadyExists.java b/test/transform/resource/before/LoggerSlf4jAlreadyExists.java index 8ac0225d..72044aa7 100644 --- a/test/transform/resource/before/LoggerSlf4jAlreadyExists.java +++ b/test/transform/resource/before/LoggerSlf4jAlreadyExists.java @@ -1,4 +1,4 @@ -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j class LoggerSlf4jAlreadyExists { int log; } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4jClassOfArray.java b/test/transform/resource/before/LoggerSlf4jClassOfArray.java deleted file mode 100644 index 87248538..00000000 --- a/test/transform/resource/before/LoggerSlf4jClassOfArray.java +++ /dev/null @@ -1,6 +0,0 @@ -@lombok.extern.slf4j.Log(String[].class) -class LoggerSlf4jClassOfArray { -} -@lombok.extern.slf4j.Log(java.lang.String[].class) -class LoggerSlf4jClassOfArrayJLS { -} diff --git a/test/transform/resource/before/LoggerSlf4jOnNonType.java b/test/transform/resource/before/LoggerSlf4jOnNonType.java index c57e171c..fd557b25 100644 --- a/test/transform/resource/before/LoggerSlf4jOnNonType.java +++ b/test/transform/resource/before/LoggerSlf4jOnNonType.java @@ -1,5 +1,5 @@ class LoggerSlf4jOnNonType { - @lombok.extern.slf4j.Log + @lombok.extern.slf4j.Slf4j void foo() { } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4jTypes.java b/test/transform/resource/before/LoggerSlf4jTypes.java index 9f221f73..d1c06fa5 100644 --- a/test/transform/resource/before/LoggerSlf4jTypes.java +++ b/test/transform/resource/before/LoggerSlf4jTypes.java @@ -1,18 +1,18 @@ -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j interface LoggerSlf4jTypesInterface { } -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j @interface LoggerSlf4jTypesAnnotation { } -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j enum LoggerSlf4jTypesEnum { } -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j enum LoggerSlf4jTypesEnumWithElement { FOO; } interface LoggerSlf4jTypesInterfaceOuter { - @lombok.extern.slf4j.Log + @lombok.extern.slf4j.Slf4j class Inner { } } \ No newline at end of file diff --git a/test/transform/resource/before/LoggerSlf4jWithClass.java b/test/transform/resource/before/LoggerSlf4jWithClass.java deleted file mode 100644 index b9cf8187..00000000 --- a/test/transform/resource/before/LoggerSlf4jWithClass.java +++ /dev/null @@ -1,12 +0,0 @@ -@lombok.extern.slf4j.Log(String.class) -class LoggerSlf4jWithClass { -} -@lombok.extern.slf4j.Log(java.util.List.class) -class LoggerSlf4jWithClassList { -} -@lombok.extern.slf4j.Log(value = java.lang.String.class) -class LoggerSlf4jWithClassValue { -} -@lombok.extern.slf4j.Log(void.class) -class LoggerSlf4jWithClassVoid { -} diff --git a/test/transform/resource/before/LoggerSlf4jWithPackage.java b/test/transform/resource/before/LoggerSlf4jWithPackage.java index efbaef68..043e889e 100644 --- a/test/transform/resource/before/LoggerSlf4jWithPackage.java +++ b/test/transform/resource/before/LoggerSlf4jWithPackage.java @@ -1,9 +1,9 @@ package before; -@lombok.extern.slf4j.Log +@lombok.extern.slf4j.Slf4j class LoggerSlf4jWithPackage { } class LoggerSlf4jWithPackageOuter { - @lombok.extern.slf4j.Log + @lombok.extern.slf4j.Slf4j static class Inner { } } \ No newline at end of file diff --git a/website/features/GetterLazy.html b/website/features/GetterLazy.html index a91e782c..d3e47b85 100644 --- a/website/features/GetterLazy.html +++ b/website/features/GetterLazy.html @@ -10,7 +10,7 @@
-

@Getter and @Setter

+

@Getter(lazy=true)

Overview

diff --git a/website/features/Log.html b/website/features/Log.html index c5d7771c..91a06580 100644 --- a/website/features/Log.html +++ b/website/features/Log.html @@ -5,34 +5,31 @@ - @Log + @Log (and friends)
-

@Log

+

@Log (and friends)

Overview

- NEW in lombok 0.10: You can annotate any field with @Log to let lombok generate a logger field automatically.
+ NEW in lombok 0.10: You can annotate any class with a log annotation to let lombok generate a logger field.
The logger is named log and field's type depends on which logger you have selected.

- There are four @Log choices available:
+ There are four choices available:

-
@lombok.extern.apachecommons.Log
+
@CommonsLog
Creates private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class);
-
@lombok.extern.jul.Log
+
@Log
Creates private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());
-
@lombok.extern.log4j.Log
+
@Log4j
Creates private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LogExample.class);
-
@lombok.extern.slf4j.Log
+
@Slf4j
Creates private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);

-

- All @Log annotations can take an optional parameter of type Class. If such a parameter is specified, that class will be used as the parameter for the logger factory call. -

@@ -51,7 +48,7 @@

If a field called log already exists, a warning will be emitted and no code will be generated.

- A future feature of lombok's @Log is to find calls to the logger field and, if the chosen logging framework supports + A future feature of lombok's diverse log annotations is to find calls to the logger field and, if the chosen logging framework supports it and the log level can be compile-time determined from the log call, guard it with an if statement. This way if the log statement ends up being ignored, the potentially expensive calculation of the log string is avoided entirely. This does mean that you should NOT put any side-effects in the expression that you log. -- cgit