diff options
-rw-r--r-- | doc/changelog.markdown | 3 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleValue.java | 1 | ||||
-rw-r--r-- | src/core/lombok/experimental/Value.java | 4 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleValue.java | 3 | ||||
-rw-r--r-- | test/transform/resource/after-delombok/ValuePlain.java | 24 | ||||
-rw-r--r-- | test/transform/resource/after-ecj/ValuePlain.java | 18 | ||||
-rw-r--r-- | usage_examples/experimental/ValueExample_post.jpage | 20 | ||||
-rw-r--r-- | website/features/experimental/Value.html | 20 |
8 files changed, 12 insertions, 81 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 33a96226..95bcf8b2 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -2,7 +2,8 @@ Lombok Changelog ---------------- ### v0.11.7 (Edgy Guinea Pig) -* FEATURE: Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](http://projectlombok.org/feature/onX.html) +* CHANGE: {Experimental} The experimental `@Value` feature no longer implies the also experimental `@Wither`. If you like your `@Value` classes to make withers, add `@Wither` to the class right next to `@Value`. +* FEATURE: {Experimental} Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](http://projectlombok.org/feature/onX.html) ### v0.11.6 (October 30th, 2012) * FEATURE: Lombok can be disabled entirely for any given compile run by using JVM switch `-Dlombok.disable`. This might be useful for code style checkers and such. diff --git a/src/core/lombok/eclipse/handlers/HandleValue.java b/src/core/lombok/eclipse/handlers/HandleValue.java index b74fbede..b69b1669 100644 --- a/src/core/lombok/eclipse/handlers/HandleValue.java +++ b/src/core/lombok/eclipse/handlers/HandleValue.java @@ -76,7 +76,6 @@ public class HandleValue extends EclipseAnnotationHandler<Value> { //and hitting 'find callers'. new HandleGetter().generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); - new HandleWither().generateWitherForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); new HandleEqualsAndHashCode().generateEqualsAndHashCodeForType(typeNode, annotationNode); new HandleToString().generateToStringForType(typeNode, annotationNode); new HandleConstructor().generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, ann.staticConstructor(), true, Collections.<Annotation>emptyList(), ast); diff --git a/src/core/lombok/experimental/Value.java b/src/core/lombok/experimental/Value.java index 6c07d2fc..048066df 100644 --- a/src/core/lombok/experimental/Value.java +++ b/src/core/lombok/experimental/Value.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Project Lombok Authors. + * Copyright (C) 2012-2013 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 @@ -29,7 +29,7 @@ import java.lang.annotation.Target; /** * Generates a lot of code which fits with a class that is a representation of an immutable entity. * <p> - * Equivalent to {@code @Getter @Wither @FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE) @RequiredArgsConstructor @ToString @EqualsAndHashCode}. + * Equivalent to {@code @Getter @FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE) @RequiredArgsConstructor @ToString @EqualsAndHashCode}. * <p> * Complete documentation is found at <a href="http://projectlombok.org/features/experimental/Value.html">the project lombok features page for @Value</a>. * diff --git a/src/core/lombok/javac/handlers/HandleValue.java b/src/core/lombok/javac/handlers/HandleValue.java index 8b0b9568..f5b10bc1 100644 --- a/src/core/lombok/javac/handlers/HandleValue.java +++ b/src/core/lombok/javac/handlers/HandleValue.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Project Lombok Authors. + * Copyright (C) 2012-2013 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 @@ -67,7 +67,6 @@ public class HandleValue extends JavacAnnotationHandler<Value> { // TODO move this to the end OR move it to the top in eclipse. new HandleConstructor().generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, true, annotationNode); new HandleGetter().generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); - new HandleWither().generateWitherForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); new HandleEqualsAndHashCode().generateEqualsAndHashCodeForType(typeNode, annotationNode); new HandleToString().generateToStringForType(typeNode, annotationNode); } diff --git a/test/transform/resource/after-delombok/ValuePlain.java b/test/transform/resource/after-delombok/ValuePlain.java index ffeed858..d1cfa3d7 100644 --- a/test/transform/resource/after-delombok/ValuePlain.java +++ b/test/transform/resource/after-delombok/ValuePlain.java @@ -15,14 +15,6 @@ final class Value1 { public String getName() { return this.name; } - @java.lang.SuppressWarnings("all") - public Value1 withX(final int x) { - return this.x == x ? this : new Value1(x, this.name); - } - @java.lang.SuppressWarnings("all") - public Value1 withName(final String name) { - return this.name == name ? this : new Value1(this.x, name); - } @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -68,14 +60,6 @@ class Value2 { public String getName() { return this.name; } - @java.lang.SuppressWarnings("all") - public Value2 withX(final int x) { - return this.x == x ? this : new Value2(x, this.name); - } - @java.lang.SuppressWarnings("all") - public Value2 withName(final String name) { - return this.name == name ? this : new Value2(this.x, name); - } @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { @@ -126,14 +110,6 @@ final class Value3 { public int getY() { return this.y; } - @java.lang.SuppressWarnings("all") - public Value3 withX(final int x) { - return this.x == x ? this : new Value3(x, this.y); - } - @java.lang.SuppressWarnings("all") - public Value3 withY(final int y) { - return this.y == y ? this : new Value3(this.x, y); - } @java.lang.Override @java.lang.SuppressWarnings("all") public boolean equals(final java.lang.Object o) { diff --git a/test/transform/resource/after-ecj/ValuePlain.java b/test/transform/resource/after-ecj/ValuePlain.java index c8498a93..b798b308 100644 --- a/test/transform/resource/after-ecj/ValuePlain.java +++ b/test/transform/resource/after-ecj/ValuePlain.java @@ -8,12 +8,6 @@ final @lombok.experimental.Value class Value1 { public @java.lang.SuppressWarnings("all") String getName() { return this.name; } - public @java.lang.SuppressWarnings("all") Value1 withX(final int x) { - return ((this.x == x) ? this : new Value1(x, this.name)); - } - public @java.lang.SuppressWarnings("all") Value1 withName(final String name) { - return ((this.name == name) ? this : new Value1(this.x, name)); - } public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { if ((o == this)) return true; @@ -54,12 +48,6 @@ final @lombok.experimental.Value class Value1 { public @java.lang.SuppressWarnings("all") String getName() { return this.name; } - public @java.lang.SuppressWarnings("all") Value2 withX(final int x) { - return ((this.x == x) ? this : new Value2(x, this.name)); - } - public @java.lang.SuppressWarnings("all") Value2 withName(final String name) { - return ((this.name == name) ? this : new Value2(this.x, name)); - } public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { if ((o == this)) return true; @@ -105,12 +93,6 @@ final @Value class Value3 { public @java.lang.SuppressWarnings("all") int getY() { return this.y; } - public @java.lang.SuppressWarnings("all") Value3 withX(final int x) { - return ((this.x == x) ? this : new Value3(x, this.y)); - } - public @java.lang.SuppressWarnings("all") Value3 withY(final int y) { - return ((this.y == y) ? this : new Value3(this.x, y)); - } public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { if ((o == this)) return true; diff --git a/usage_examples/experimental/ValueExample_post.jpage b/usage_examples/experimental/ValueExample_post.jpage index 47de72a5..ac9b64d1 100644 --- a/usage_examples/experimental/ValueExample_post.jpage +++ b/usage_examples/experimental/ValueExample_post.jpage @@ -30,18 +30,6 @@ public final class ValueExample { return this.tags; } - public ValueExample withName(String name) { - return this.name == name ? this : new ValueExample(name, age, score, tags); - } - - public ValueExample withScore(double score) { - return this.score == score ? this : new ValueExample(name, age, score, tags); - } - - public ValueExample withTags(String[] tags) { - return this.tags == tags ? this : new ValueExample(name, age, score, tags); - } - @java.lang.Override public boolean equals(Object o) { if (o == this) return true; @@ -99,14 +87,6 @@ public final class ValueExample { return this.value; } - public Exercise<T> withName(String name) { - return this.name == name ? this : new Exercise<T>(name, value); - } - - public Exercise<T> withValue(T value) { - return this.value == value ? this : new Exercise<T>(name, value); - } - @java.lang.Override public boolean equals(Object o) { if (o == this) return true; diff --git a/website/features/experimental/Value.html b/website/features/experimental/Value.html index fb726d7b..d2acfee4 100644 --- a/website/features/experimental/Value.html +++ b/website/features/experimental/Value.html @@ -15,8 +15,9 @@ <div class="since"> <h3>Since</h3> <p> - @Value was introduced as experimental feature in lombok v0.11.4. - </p> + <code>@Value</code> was introduced as experimental feature in lombok v0.11.4. + </p><p> + <code>@Value</code> no longer implies <code>@Wither</code> since lombok v0.11.8. </div> <div class="experimental"> <h3>Experimental</h3> @@ -24,19 +25,16 @@ Experimental because: <ul> <li>Various choices still have to be vetted as being the correct 'least surprise' choice: Should the class be made final by default, etc.</li> - <li>Dependent on @Wither which is experimental.</li> </ul> Current status: <em>positive</em> - Currently we feel this feature may move out of experimental status with no or minor changes soon. </div> <div class="overview"> <h3>Overview</h3> <p> - <code>@Value</code> is the immutable variant of <a href="../Data.html"><code>@Data</code></a>; all fields are made <code>private</code> and <code>final</code> by default, and instead of setters, each field gets a so-called 'wither', - which is a method that produces a clone with each field having the same value, except for the field you want a new value for. The class itself is also made <code>final</code> by default, because immutability is not something that can - be forced onto a subclass. Like <code>@Data</code>, useful <code>toString()</code>, <code>equals()</code> and <code>hashCode()</code> methods are also generated, each field gets a getter method, and a constructor that covers every + <code>@Value</code> is the immutable variant of <a href="../Data.html"><code>@Data</code></a>; all fields are made <code>private</code> and <code>final</code> by default, and setters are not generated. The class itself is also made <code>final</code> by default, because immutability is not something that can be forced onto a subclass. Like <code>@Data</code>, useful <code>toString()</code>, <code>equals()</code> and <code>hashCode()</code> methods are also generated, each field gets a getter method, and a constructor that covers every argument (except <code>final</code> fields that are initialized in the field declaration) is also generated. </p><p> - In practice, <code>@Value</code> is shorthand for: <code>final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter @Wither</code>. + In practice, <code>@Value</code> is shorthand for: <code>final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter</code>. </p><p> It is possible to override the final-by-default and private-by-default behaviour using either an explicit access level on a field, or by using the <code>@NonFinal</code> or <code>@PackagePrivate</code> annotations.<br /> It is possible to override any default behaviour for any of the 'parts' that make up <code>@Value</code> by explicitly using that annotation. @@ -57,13 +55,9 @@ <div class="overview"> <h3>Small print</h3><div class="smallprint"> <p> - Look for the documentation on the 'parts' of <code>@Value</code>: <a href="../ToString.html"><code>@ToString</code></a>, <a href="../EqualsAndHashCode.html"><code>@EqualsAndHashCode</code></a>, - <a href="../Constructor.html"><code>@AllArgsConstructor</code></a>, <a href="FieldDefaults.html"><code>@FieldDefaults</code></a>, <a href="../GetterSetter.html"><code>@Getter</code></a>, - <a href="Wither.html"><code>@Wither</code></a>. + Look for the documentation on the 'parts' of <code>@Value</code>: <a href="../ToString.html"><code>@ToString</code></a>, <a href="../EqualsAndHashCode.html"><code>@EqualsAndHashCode</code></a>, <a href="../Constructor.html"><code>@AllArgsConstructor</code></a>, <a href="FieldDefaults.html"><code>@FieldDefaults</code></a>, and <a href="../GetterSetter.html"><code>@Getter</code></a>. </p><p> - For classes with generics, it's useful to have a static method which serves as a constructor, because inference of generic parameters via static methods works in java6 and avoids having to use the diamond operator. - While you can force this by applying an explicit <code>@AllArgsConstructor</code> annotation, there's also the <code>@Value(staticConstructor="of")</code> feature, which will make the generated all-arguments constructor - private, and generates a public static method named <code>of</code> which is a wrapper around this private constructor. + For classes with generics, it's useful to have a static method which serves as a constructor, because inference of generic parameters via static methods works in java6 and avoids having to use the diamond operator. While you can force this by applying an explicit <code>@AllArgsConstructor(staticConstructor="of")</code> annotation, there's also the <code>@Value(staticConstructor="of")</code> feature, which will make the generated all-arguments constructor private, and generates a public static method named <code>of</code> which is a wrapper around this private constructor. </p> </div> </div> |