diff options
| author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-04-10 00:12:24 +0200 |
|---|---|---|
| committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-04-10 00:23:49 +0200 |
| commit | 57fb2b9773d96777ba343e28e5e2ae4d6fa96f42 (patch) | |
| tree | 267a4d14f3ead6079d7383198a0705a675d7c9bd | |
| parent | 4dce9a351d2e459fb2d03bdb9c99b62a2b29f8d0 (diff) | |
| download | lombok-57fb2b9773d96777ba343e28e5e2ae4d6fa96f42.tar.gz lombok-57fb2b9773d96777ba343e28e5e2ae4d6fa96f42.tar.bz2 lombok-57fb2b9773d96777ba343e28e5e2ae4d6fa96f42.zip | |
[website] Whoops we had 2 copies of usage_examples. Fixed that by deleting the one that was NOT being used for the website.
54 files changed, 21 insertions, 1453 deletions
diff --git a/usage_examples/BuilderExample_post.jpage b/usage_examples/BuilderExample_post.jpage deleted file mode 100644 index 0b64703c..00000000 --- a/usage_examples/BuilderExample_post.jpage +++ /dev/null @@ -1,87 +0,0 @@ -import java.util.Set; - -public class BuilderExample { - private long created; - private String name; - private int age; - private Set<String> occupations; - - BuilderExample(String name, int age, Set<String> occupations) { - this.name = name; - this.age = age; - this.occupations = occupations; - } - - private static long $default$created() { - return System.currentTimeMillis(); - } - - public static BuilderExampleBuilder builder() { - return new BuilderExampleBuilder(); - } - - public static class BuilderExampleBuilder { - private long created; - private boolean created$set; - private String name; - private int age; - private java.util.ArrayList<String> occupations; - - BuilderExampleBuilder() { - } - - public BuilderExampleBuilder created(long created) { - this.created = created; - this.created$set = true; - return this; - } - - public BuilderExampleBuilder name(String name) { - this.name = name; - return this; - } - - public BuilderExampleBuilder age(int age) { - this.age = age; - return this; - } - - public BuilderExampleBuilder occupation(String occupation) { - if (this.occupations == null) { - this.occupations = new java.util.ArrayList<String>(); - } - - this.occupations.add(occupation); - return this; - } - - public BuilderExampleBuilder occupations(Collection<? extends String> occupations) { - if (this.occupations == null) { - this.occupations = new java.util.ArrayList<String>(); - } - - this.occupations.addAll(occupations); - return this; - } - - public BuilderExampleBuilder clearOccupations() { - if (this.occupations != null) { - this.occupations.clear(); - } - - return this; - } - - public BuilderExample build() { - // complicated switch statement to produce a compact properly sized immutable set omitted. - // go to https://projectlombok.org/features/Singular-snippet.html to see it. - Set<String> occupations = ...; - return new BuilderExample(created$set ? created : BuilderExample.$default$created(), name, age, occupations); - } - - @java.lang.Override - public String toString() { - return "BuilderExample.BuilderExampleBuilder(created = " + this.created + ", name = " + this.name + ", age = " + this.age + ", occupations = " + this.occupations + ")"; - } - } -}
\ No newline at end of file diff --git a/usage_examples/BuilderExample_pre.jpage b/usage_examples/BuilderExample_pre.jpage deleted file mode 100644 index 3b1b0df2..00000000 --- a/usage_examples/BuilderExample_pre.jpage +++ /dev/null @@ -1,11 +0,0 @@ -import lombok.Builder; -import lombok.Singular; -import java.util.Set; - -@Builder -public class BuilderExample { - @Builder.Default private long created = System.currentTimeMillis(); - private String name; - private int age; - @Singular private Set<String> occupations; -} diff --git a/usage_examples/CleanupExample_post.jpage b/usage_examples/CleanupExample_post.jpage deleted file mode 100644 index 7e87c153..00000000 --- a/usage_examples/CleanupExample_post.jpage +++ /dev/null @@ -1,26 +0,0 @@ -import java.io.*; - -public class CleanupExample { - public static void main(String[] args) throws IOException { - InputStream in = new FileInputStream(args[0]); - try { - OutputStream out = new FileOutputStream(args[1]); - try { - byte[] b = new byte[10000]; - while (true) { - int r = in.read(b); - if (r == -1) break; - out.write(b, 0, r); - } - } finally { - if (out != null) { - out.close(); - } - } - } finally { - if (in != null) { - in.close(); - } - } - } -} diff --git a/usage_examples/CleanupExample_pre.jpage b/usage_examples/CleanupExample_pre.jpage deleted file mode 100644 index 9f639171..00000000 --- a/usage_examples/CleanupExample_pre.jpage +++ /dev/null @@ -1,15 +0,0 @@ -import lombok.Cleanup; -import java.io.*; - -public class CleanupExample { - public static void main(String[] args) throws IOException { - @Cleanup InputStream in = new FileInputStream(args[0]); - @Cleanup OutputStream out = new FileOutputStream(args[1]); - byte[] b = new byte[10000]; - while (true) { - int r = in.read(b); - if (r == -1) break; - out.write(b, 0, r); - } - } -} diff --git a/usage_examples/ConstructorExample_post.jpage b/usage_examples/ConstructorExample_post.jpage deleted file mode 100644 index 8a2d5069..00000000 --- a/usage_examples/ConstructorExample_post.jpage +++ /dev/null @@ -1,28 +0,0 @@ -public class ConstructorExample<T> { - private int x, y; - @NonNull private T description; - - private ConstructorExample(T description) { - if (description == null) throw new NullPointerException("description"); - this.description = description; - } - - public static <T> ConstructorExample<T> of(T description) { - return new ConstructorExample<T>(description); - } - - @java.beans.ConstructorProperties({"x", "y", "description"}) - protected ConstructorExample(int x, int y, T description) { - if (description == null) throw new NullPointerException("description"); - this.x = x; - this.y = y; - this.description = description; - } - - public static class NoArgsExample { - @NonNull private String field; - - public NoArgsExample() { - } - } -} diff --git a/usage_examples/ConstructorExample_pre.jpage b/usage_examples/ConstructorExample_pre.jpage deleted file mode 100644 index ac0d3c28..00000000 --- a/usage_examples/ConstructorExample_pre.jpage +++ /dev/null @@ -1,16 +0,0 @@ -import lombok.AccessLevel; -import lombok.RequiredArgsConstructor; -import lombok.AllArgsConstructor; -import lombok.NonNull; - -@RequiredArgsConstructor(staticName = "of") -@AllArgsConstructor(access = AccessLevel.PROTECTED) -public class ConstructorExample<T> { - private int x, y; - @NonNull private T description; - - @NoArgsConstructor - public static class NoArgsExample { - @NonNull private String field; - } -} diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage deleted file mode 100644 index bef0a0f1..00000000 --- a/usage_examples/DataExample_post.jpage +++ /dev/null @@ -1,119 +0,0 @@ -import java.util.Arrays; - -public class DataExample { - private final String name; - private int age; - private double score; - private String[] tags; - - public DataExample(String name) { - this.name = name; - } - - public String getName() { - return this.name; - } - - void setAge(int age) { - this.age = age; - } - - public int getAge() { - return this.age; - } - - public void setScore(double score) { - this.score = score; - } - - public double getScore() { - return this.score; - } - - public String[] getTags() { - return this.tags; - } - - public void setTags(String[] tags) { - this.tags = tags; - } - - @Override public String toString() { - return "DataExample(" + this.getName() + ", " + this.getAge() + ", " + this.getScore() + ", " + Arrays.deepToString(this.getTags()) + ")"; - } - - protected boolean canEqual(Object other) { - return other instanceof DataExample; - } - - @Override public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof DataExample)) return false; - DataExample other = (DataExample) o; - if (!other.canEqual((Object)this)) return false; - if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; - if (this.getAge() != other.getAge()) return false; - if (Double.compare(this.getScore(), other.getScore()) != 0) return false; - if (!Arrays.deepEquals(this.getTags(), other.getTags())) return false; - return true; - } - - @Override public int hashCode() { - final int PRIME = 59; - int result = 1; - final long temp1 = Double.doubleToLongBits(this.getScore()); - result = (result*PRIME) + (this.getName() == null ? 43 : this.getName().hashCode()); - result = (result*PRIME) + this.getAge(); - result = (result*PRIME) + (int)(temp1 ^ (temp1 >>> 32)); - result = (result*PRIME) + Arrays.deepHashCode(this.getTags()); - return result; - } - - public static class Exercise<T> { - private final String name; - private final T value; - - private Exercise(String name, T value) { - this.name = name; - this.value = value; - } - - public static <T> Exercise<T> of(String name, T value) { - return new Exercise<T>(name, value); - } - - public String getName() { - return this.name; - } - - public T getValue() { - return this.value; - } - - @Override public String toString() { - return "Exercise(name=" + this.getName() + ", value=" + this.getValue() + ")"; - } - - protected boolean canEqual(Object other) { - return other instanceof Exercise; - } - - @Override public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof Exercise)) return false; - Exercise<?> other = (Exercise<?>) o; - if (!other.canEqual((Object)this)) return false; - if (this.getName() == null ? other.getValue() != null : !this.getName().equals(other.getName())) return false; - if (this.getValue() == null ? other.getValue() != null : !this.getValue().equals(other.getValue())) return false; - return true; - } - - @Override public int hashCode() { - final int PRIME = 59; - int result = 1; - result = (result*PRIME) + (this.getName() == null ? 43 : this.getName().hashCode()); - result = (result*PRIME) + (this.getValue() == null ? 43 : this.getValue().hashCode()); - return result; - } - } -} diff --git a/usage_examples/DataExample_pre.jpage b/usage_examples/DataExample_pre.jpage deleted file mode 100644 index 404d3458..00000000 --- a/usage_examples/DataExample_pre.jpage +++ /dev/null @@ -1,18 +0,0 @@ -import lombok.AccessLevel; -import lombok.Setter; -import lombok.Data; -import lombok.ToString; - -@Data public class DataExample { - private final String name; - @Setter(AccessLevel.PACKAGE) private int age; - private double score; - private String[] tags; - - @ToString(includeFieldNames=true) - @Data(staticConstructor="of") - public static class Exercise<T> { - private final String name; - private final T value; - } -} diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage deleted file mode 100644 index 91e78250..00000000 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ /dev/null @@ -1,72 +0,0 @@ -import java.util.Arrays; - -public class EqualsAndHashCodeExample { - private transient int transientVar = 10; - private String name; - private double score; - private Shape shape = new Square(5, 10); - private String[] tags; - private int id; - - public String getName() { - return this.name; - } - - @Override public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof EqualsAndHashCodeExample)) return false; - EqualsAndHashCodeExample other = (EqualsAndHashCodeExample) o; - if (!other.canEqual((Object)this)) return false; - if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; - if (Double.compare(this.score, other.score) != 0) return false; - if (!Arrays.deepEquals(this.tags, other.tags)) return false; - return true; - } - - @Override public int hashCode() { - final int PRIME = 59; - int result = 1; - final long temp1 = Double.doubleToLongBits(this.score); - result = (result*PRIME) + (this.name == null ? 43 : this.name.hashCode()); - result = (result*PRIME) + (int)(temp1 ^ (temp1 >>> 32)); - result = (result*PRIME) + Arrays.deepHashCode(this.tags); - return result; - } - - protected boolean canEqual(Object other) { - return other instanceof EqualsAndHashCodeExample; - } - - public static class Square extends Shape { - private final int width, height; - - public Square(int width, int height) { - this.width = width; - this.height = height; - } - - @Override public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof Square)) return false; - Square other = (Square) o; - if (!other.canEqual((Object)this)) return false; - if (!super.equals(o)) return false; - if (this.width != other.width) return false; - if (this.height != other.height) return false; - return true; - } - - @Override public int hashCode() { - final int PRIME = 59; - int result = 1; - result = (result*PRIME) + super.hashCode(); - result = (result*PRIME) + this.width; - result = (result*PRIME) + this.height; - return result; - } - - protected boolean canEqual(Object other) { - return other instanceof Square; - } - } -} diff --git a/usage_examples/EqualsAndHashCodeExample_pre.jpage b/usage_examples/EqualsAndHashCodeExample_pre.jpage deleted file mode 100644 index 64faf59f..00000000 --- a/usage_examples/EqualsAndHashCodeExample_pre.jpage +++ /dev/null @@ -1,25 +0,0 @@ -import lombok.EqualsAndHashCode; - -@EqualsAndHashCode(exclude={"id", "shape"}) -public class EqualsAndHashCodeExample { - private transient int transientVar = 10; - private String name; - private double score; - private Shape shape = new Square(5, 10); - private String[] tags; - private int id; - - public String getName() { - return this.name; - } - - @EqualsAndHashCode(callSuper=true) - public static class Square extends Shape { - private final int width, height; - - public Square(int width, int height) { - this.width = width; - this.height = height; - } - } -} diff --git a/usage_examples/GetterLazyExample_post.jpage b/usage_examples/GetterLazyExample_post.jpage deleted file mode 100644 index 5f34c43e..00000000 --- a/usage_examples/GetterLazyExample_post.jpage +++ /dev/null @@ -1,26 +0,0 @@ -public class GetterLazyExample { - private final java.util.concurrent.AtomicReference<java.lang.Object> cached = new java.util.concurrent.AtomicReference<java.lang.Object>(); - - public double[] getCached() { - java.lang.Object value = this.cached.get(); - if (value == null) { - synchronized(this.cached) { - value = this.cached.get(); - if (value == null) { - final double[] actualValue = expensive(); - value = actualValue == null ? this.cached : actualValue; - this.cached.set(value); - } - } - } - return (double[])(value == this.cached ? null : value); - } - - private double[] expensive() { - double[] result = new double[1000000]; - for (int i = 0; i < result.length; i++) { - result[i] = Math.asin(i); - } - return result; - } -} diff --git a/usage_examples/GetterLazyExample_pre.jpage b/usage_examples/GetterLazyExample_pre.jpage deleted file mode 100644 index ca6c9d58..00000000 --- a/usage_examples/GetterLazyExample_pre.jpage +++ /dev/null @@ -1,13 +0,0 @@ -import lombok.Getter; - -public class GetterLazyExample { - @Getter(lazy=true) private final double[] cached = expensive(); - - private double[] expensive() { - double[] result = new double[1000000]; - for (int i = 0; i < result.length; i++) { - result[i] = Math.asin(i); - } - return result; - } -} diff --git a/usage_examples/GetterSetterExample_post.jpage b/usage_examples/GetterSetterExample_post.jpage deleted file mode 100644 index 241a3a4e..00000000 --- a/usage_examples/GetterSetterExample_post.jpage +++ /dev/null @@ -1,42 +0,0 @@ -public class GetterSetterExample { - /** - * Age of the person. Water is wet. - */ - private int age = 10; - - /** - * Name of the person. - */ - private String name; - - @Override public String toString() { - return String.format("%s (age: %d)", name, age); - } - - /** - * Age of the person. Water is wet. - * - * @return The current value of this person's age. Circles are round. - */ - public int getAge() { - return age; - } - - /** - * Age of the person. Water is wet. - * - * @param age New value for this person's age. Sky is blue. - */ - public void setAge(int age) { - this.age = age; - } - - /** - * Changes the name of this person. - * - * @param name The new value. - */ - protected void setName(String name) { - this.name = name; - } -} diff --git a/usage_examples/GetterSetterExample_pre.jpage b/usage_examples/GetterSetterExample_pre.jpage deleted file mode 100644 index 4183aa5d..00000000 --- a/usage_examples/GetterSetterExample_pre.jpage +++ /dev/null @@ -1,26 +0,0 @@ -import lombok.AccessLevel; -import lombok.Getter; -import lombok.Setter; - -public class GetterSetterExample { - /** - * Age of the person. Water is wet. - * - * @param age New value for this person's age. Sky is blue. - * @return The current value of this person's age. Circles are round. - */ - @Getter @Setter private int age = 10; - - /** - * Name of the person. - * -- SETTER -- - * Changes the name of this person. - * - * @param name The new value. - */ - @Setter(AccessLevel.PROTECTED) private String name; - - @Override public String toString() { - return String.format("%s (age: %d)", name, age); - } -} diff --git a/usage_examples/LogExample_post.jpage b/usage_examples/LogExample_post.jpage deleted file mode 100644 index eab3b046..00000000 --- a/usage_examples/LogExample_post.jpage +++ /dev/null @@ -1,23 +0,0 @@ -public class LogExample { - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName()); - - public static void main(String... args) { - log.error("Something's wrong here"); - } -} - -public class LogExampleOther { - private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExampleOther.class); - - public static void main(String... args) { - log.error("Something else is wrong here"); - } |
