mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 20:15:59 +00:00
Updated the javadoc of each and every feature annotation that lombok has:
* Removed most documentation and instead put in a link to the much more up to date and extensive documentation at http://projectlombok.org/features * Getting ahead of ourselves a little, added notes on onConstructor/onParam/onMethod which we are about to add in the next few commits. * Updated copyrights to 2012.
This commit is contained in:
1 parent
e95bb83e06
commit
58851b4c6e
23 files changed
+113
-140
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2012 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
|
||||
@@ -27,8 +27,12 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Generates an all-args constructor. An all-args constructor requires one argument
|
||||
* for every field in the class.
|
||||
* Generates an all-args constructor.
|
||||
* An all-args constructor requires one argument for every field in the class.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Constructor.html">the project lombok features page for @Constructor</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
|
||||
*
|
||||
* @see NoArgsConstructor
|
||||
* @see RequiredArgsConstructor
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.lang.annotation.Target;
|
||||
* of what happens. Implemented by wrapping all statements following the local variable declaration to the
|
||||
* end of your scope into a try block that, as a finally action, closes the resource.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Cleanup.html">the project lombok features page for @Cleanup</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* public void copyFile(String in, String out) throws IOException {
|
||||
@@ -59,20 +61,13 @@ import java.lang.annotation.Target;
|
||||
* outStream.write(b, 0, r);
|
||||
* }
|
||||
* } finally {
|
||||
* out.close();
|
||||
* if (out != null) out.close();
|
||||
* }
|
||||
* } finally {
|
||||
* in.close();
|
||||
* if (in != null) in.close();
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Note that the final close method call, if it throws an exception, will overwrite any exception thrown
|
||||
* in the main body of the generated try block. You should NOT rely on this behaviour - future versions of
|
||||
* lombok intend to silently swallow any exception thrown by the cleanup method <i>_IF</i> the main body
|
||||
* throws an exception as well, as the earlier exception is usually far more useful.
|
||||
* <p>
|
||||
* However, in java 1.6, generating the code to do this is prohibitively complicated.
|
||||
*/
|
||||
@Target(ElementType.LOCAL_VARIABLE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
+10
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 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
|
||||
@@ -30,17 +30,16 @@ import java.lang.annotation.Target;
|
||||
* Generates getters for all fields, a useful toString method, and hashCode and equals implementations that check
|
||||
* all non-transient fields. Will also generate setters for all non-final fields, as well as a constructor.
|
||||
* <p>
|
||||
* If any method to be generated already exists (in name and parameter count - the return type or parameter types are not relevant), then
|
||||
* that method will not be generated by the Data annotation.
|
||||
* Equivalent to {@code @Getter @Setter @RequiredArgsConstructor @ToString @EqualsAndHashCode}.
|
||||
* <p>
|
||||
* The generated constructor will have 1 parameter for each final field. The generated toString will print all fields,
|
||||
* while the generated hashCode and equals take into account all non-transient fields.<br>
|
||||
* Static fields are skipped (no getter or setter, and they are not included in toString, equals, hashCode, or the constructor).
|
||||
* <p>
|
||||
* {@code toString}, {@code equals}, and {@code hashCode} use the deepX variants in the
|
||||
* {@code java.util.Arrays} utility class. Therefore, if your class has arrays that contain themselves,
|
||||
* these methods will just loop endlessly until the inevitable {@code StackOverflowError}. This behaviour
|
||||
* is no different from {@code java.util.ArrayList}, though.
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Data.html">the project lombok features page for @Data</a>.
|
||||
*
|
||||
* @see Getter
|
||||
* @see Setter
|
||||
* @see RequiredArgsConstructor
|
||||
* @see ToString
|
||||
* @see EqualsAndHashCode
|
||||
* @see lombok.experimental.Value
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2012 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
|
||||
@@ -39,6 +39,8 @@ import java.lang.annotation.Target;
|
||||
* All public instance methods of the field's type, as well as all public instance methods of all the field's type's superfields are delegated, except for all methods
|
||||
* that exist in {@link Object}, the {@code canEqual(Object)} method, and any methods that appear in types
|
||||
* that are listed in the {@code excludes} property.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Delegate.html">the project lombok features page for @Delegate</a>.
|
||||
*/
|
||||
@Target({ElementType.FIELD, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 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
|
||||
@@ -27,31 +27,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Generates implementations for the {@code equals} and {@code hashCode} methods inherited by all objects.
|
||||
* Generates implementations for the {@code equals} and {@code hashCode} methods inherited by all objects, based on relevant fields.
|
||||
* <p>
|
||||
* If either method already exists, then {@code @EqualsAndHashCode} will not generate that particular method.
|
||||
* If they all exist, {@code @EqualsAndHashCode} generates no methods, and emits a warning instead to highlight
|
||||
* that its doing nothing at all. The parameter list and return type are not relevant when deciding to skip generation of
|
||||
* a method; any method named {@code hashCode} will make {@code @EqualsAndHashCode} not generate that method,
|
||||
* for example.
|
||||
* <p>
|
||||
* By default, all fields that are non-static and non-transient are used in the equality check and hashCode generation.
|
||||
* You can exclude more fields by specifying them in the {@code exclude} parameter. You can also explicitly specify
|
||||
* the fields that are to be used by specifying them in the {@code of} parameter.
|
||||
* <p>
|
||||
* Normally, auto-generating {@code hashCode} and {@code equals} implementations in a subclass is a bad idea, as
|
||||
* the superclass also defines fields, for which equality checks/hashcodes won't be auto-generated. Therefore, a warning
|
||||
* is emitted when you try. Instead, you can set the {@code callSuper} parameter to <em>true</em> which will call
|
||||
* {@code super.equals} and {@code super.hashCode}. Doing this with {@code java.lang.Object} as superclass is
|
||||
* pointless, so, conversely, setting this flag when <em>NOT</em> extending something (other than Object) will also generate
|
||||
* a warning. Be aware that not all implementations of {@code equals} correctly handle being called from a subclass!
|
||||
* Fortunately, lombok-generated {@code equals} implementations do correctly handle it.
|
||||
* <p>
|
||||
* Array fields are handled by way of {@link java.util.Arrays#deepEquals(Object[], Object[])} where necessary, as well
|
||||
* as {@code deepHashCode}. The downside is that arrays with circular references (arrays that contain themselves,
|
||||
* possibly indirectly) results in calls to {@code hashCode} and {@code equals} throwing a
|
||||
* {@link java.lang.StackOverflowError}. However, the implementations for java's own {@link java.util.ArrayList} suffer
|
||||
* from the same flaw.
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/EqualsAndHashCode.html">the project lombok features page for @EqualsAndHashCode</a>.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -28,7 +28,11 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Put on any field to make lombok build a standard getter.
|
||||
*
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/GetterSetter.html">the project lombok features page for @Getter and @Setter</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onMethod} parameter. See the full documentation for more details.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* private @Getter int foo;
|
||||
@@ -41,12 +45,6 @@ import java.lang.annotation.Target;
|
||||
* return this.foo;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Note that fields of type {@code boolean} (but not {@code java.lang.Boolean}) will result in an
|
||||
* {@code isFoo} name instead of {@code getFoo}.
|
||||
* <p>
|
||||
* If any method named {@code getFoo}/{@code isFoo} (case insensitive) exists, regardless of return type or parameters,
|
||||
* no method is generated, and instead a compiler warning is emitted.
|
||||
* <p>
|
||||
* This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have
|
||||
* a {@code @Getter} annotation have the annotation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2012 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
|
||||
@@ -27,11 +27,14 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Generates a no-args constructor. Will generate an error message if such
|
||||
* a constructor cannot be written due to the existence of final fields.
|
||||
*
|
||||
* NB: Fields with constraints such as {@code @NonNull} will <em>NOT</em> be checked
|
||||
* in such a constructor, of course!
|
||||
* Generates a no-args constructor.
|
||||
* Will generate an error message if such a constructor cannot be written due to the existence of final fields.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Constructor.html">the project lombok features page for @Constructor</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
|
||||
* <p>
|
||||
* NB: Fields with constraints such as {@code @NonNull} will <em>NOT</em> be checked in a {@code @NoArgsConstructor} constructor, of course!
|
||||
*
|
||||
* @see RequiredArgsConstructor
|
||||
* @see AllArgsConstructor
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2012 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,11 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Generates a constructor with required arguments.
|
||||
* Required arguments are final fields and fields with constraints such as {@code @NonNull}.
|
||||
*
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Constructor.html">the project lombok features page for @Constructor</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onConstructor} parameter. See the full documentation for more details.
|
||||
*
|
||||
* @see NoArgsConstructor
|
||||
* @see AllArgsConstructor
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,10 @@ import java.lang.annotation.Target;
|
||||
/**
|
||||
* Put on any field to make lombok build a standard setter.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/GetterSetter.html">the project lombok features page for @Getter and @Setter</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onParam} and {@code onMethod} parameter. See the full documentation for more details.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* private @Setter int foo;
|
||||
@@ -42,8 +46,6 @@ import java.lang.annotation.Target;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* If any method named {@code setFoo} (case insensitive) exists, regardless of return type or parameters,
|
||||
* no method is generated, and instead a compiler warning is emitted.
|
||||
* <p>
|
||||
* This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have
|
||||
* a {@code Setter} annotation have the annotation.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 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
|
||||
@@ -34,21 +34,7 @@ import java.lang.annotation.Target;
|
||||
* checked exception types. The JVM does not check for the consistency of the checked exception system; javac does,
|
||||
* and this annotation lets you opt out of its mechanism.
|
||||
* <p>
|
||||
* You should use this annotation ONLY in the following two cases:<ol>
|
||||
* <li>You are certain the listed exception can't actually ever happen, or only in vanishingly rare situations.
|
||||
* You don't try to catch OutOfMemoryError on every statement either. Examples:<br>
|
||||
* {@code IOException} in {@code ByteArrayOutputStream}<br>
|
||||
* {@code UnsupportedEncodingException} in new String(byteArray, "UTF-8").</li>
|
||||
* <li>You know for certain the caller can handle the exception (for example, because the caller is
|
||||
* an app manager that will handle all throwables that fall out of your method the same way), but due
|
||||
* to interface restrictions you can't just add these exceptions to your 'throws' clause.
|
||||
* <p>
|
||||
* Note that, as SneakyThrow is an implementation detail and <i>NOT</i> part of your method signature, it is
|
||||
* a compile time error if none of the statements in your method body can throw a listed exception.
|
||||
* <p>
|
||||
* <b><i>WARNING: </b></i>You must have lombok.jar available at the runtime of your app if you use SneakyThrows,
|
||||
* because your code is rewritten to use {@link Lombok#sneakyThrow(Throwable)}.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/SneakyThrows.html">the project lombok features page for @SneakyThrows</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
@@ -58,10 +44,17 @@ import java.lang.annotation.Target;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* {@code @SneakyThrows} without a parameter defaults to allowing <i>every</i> checked exception.
|
||||
* (The default is {@code Throwable.class}).
|
||||
*
|
||||
* @see Lombok#sneakyThrow(Throwable)
|
||||
* Becomes:
|
||||
* <pre>
|
||||
* public void utf8ToString(byte[] bytes) {
|
||||
* try {
|
||||
* return new String(bytes, "UTF-8");
|
||||
* } catch (UnsupportedEncodingException $uniqueName) {
|
||||
* throw useMagicTrickeryToHideThisFromTheCompiler($uniqueName);
|
||||
* // This trickery involves a bytecode transformer run automatically during the final stages of compilation;
|
||||
* // there is no runtime dependency on lombok.
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2011 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 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
|
||||
@@ -34,6 +34,8 @@ import java.lang.annotation.Target;
|
||||
* For non-static methods, a field named {@code $lock} is used, and for static methods,
|
||||
* {@code $LOCK} is used. These will be generated if needed and if they aren't already present. The contents
|
||||
* of the fields will be serializable.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Synchronized.html">the project lombok features page for @Synchronized</a>.
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2009-2012 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
|
||||
@@ -27,28 +27,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Generates an implementation for the {@code toString} method inherited by all objects.
|
||||
* Generates an implementation for the {@code toString} method inherited by all objects, consisting of printing the values of relevant fields.
|
||||
* <p>
|
||||
* If the method already exists, then {@code ToString} will not generate any method, and instead warns
|
||||
* that it's doing nothing at all. The parameter list and return type are not relevant when deciding to skip generation of
|
||||
* the method; any method named {@code toString} will make {@code ToString} not generate anything.
|
||||
* <p>
|
||||
* By default, all fields that are non-static are used in the toString generation. You can exclude fields by specifying them
|
||||
* in the {@code exclude} parameter. You can also explicitly specify the fields that
|
||||
* are to be used by specifying them in the {@code of} parameter.
|
||||
* <p>
|
||||
* Array fields are handled by way of {@link java.util.Arrays#deepToString(Object[])} where necessary.
|
||||
* The downside is that arrays with circular references (arrays that contain themselves,
|
||||
* possibly indirectly) results in calls to {@code toString} throwing a
|
||||
* {@link java.lang.StackOverflowError}. However, the implementations for java's own {@link java.util.ArrayList} suffer
|
||||
* from the same flaw.
|
||||
* <p>
|
||||
* The {@code toString} method that is generated will print the class name as well as each field (both the name
|
||||
* and the value). You can optionally choose to suppress the printing of the field name, by setting the
|
||||
* {@code includeFieldNames} flag to <em>false</em>.
|
||||
* <p>
|
||||
* You can also choose to include the result of {@code toString} in your class's superclass by setting the
|
||||
* {@code callSuper} to <em>true</em>.
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/ToString.html">the project lombok features page for @ToString</a>.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* A container for settings for the generation of getters and setters.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/experimental/Accessors.html">the project lombok features page for @Accessors</a>.
|
||||
* <p>
|
||||
* Using this annotation does nothing by itself; an annotation that makes lombok generate getters and setters,
|
||||
* such as {@link lombok.Setter} or {@link lombok.Data} is also required.
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,9 @@ import java.lang.annotation.*;
|
||||
* otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as
|
||||
* if they were instance methods on the extended type.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/experimental/ExtensionMethod.html">the project lombok features page for @ExtensionMethod</a>.
|
||||
* <p>
|
||||
* <p>
|
||||
* Before:
|
||||
*
|
||||
* <pre>
|
||||
|
||||
@@ -30,12 +30,13 @@ import lombok.AccessLevel;
|
||||
|
||||
/**
|
||||
* Adds modifiers to each field in the type with this annotation.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/experimental/FieldDefaults.html">the project lombok features page for @FieldDefaults</a>.
|
||||
* <p>
|
||||
* If {@code makeFinal} is {@code true}, then each field that is not annotated with {@code @NonFinal} will have the {@code final} modifier added.
|
||||
* <p>
|
||||
* If {@code level} is set, then each field that is package private (i.e. no access modifier) and does not have the {@code @PackagePrivate} annotation will
|
||||
* have the appropriate access level modifier added.
|
||||
* <p>
|
||||
* The only fields that are skipped are those that start with a '$'; everything else, including static, volatile, and transient fields, are modified.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -28,30 +28,17 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Generates a lot of code which fits with a class that is a representation of an immutable entity.
|
||||
* Specifically, it generates:<ul>
|
||||
* <li>Getters for all fields
|
||||
* <li>toString method
|
||||
* <li>hashCode and equals implementations that check all non-transient fields.
|
||||
* <li>Generates withers for all fields (except final fields that are initialized in the field declaration itself)
|
||||
* <li>Generates a constructor for each argument
|
||||
* <li>Adds {@code private} and {@code final} to each field.
|
||||
* <li>Makes the class itself final.
|
||||
* </ul>
|
||||
* <p>
|
||||
* Equivalent to {@code @Getter @Wither @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>.
|
||||
*
|
||||
* In other words, {@code @Value} is a shorthand for:<br />
|
||||
* {@code final @Getter @Wither @FieldDefaults(makeFinal=true,level=AccessLevel.PRIVATE) @EqualsAndHashCode @ToString @AllArgsConstructor}.
|
||||
* <p>
|
||||
* If any method to be generated already exists (in name and parameter count - the return type or parameter types are not relevant), then
|
||||
* that method will not be generated by the Value annotation.
|
||||
* <p>
|
||||
* The generated constructor will have 1 parameter for each field. The generated toString will print all fields,
|
||||
* while the generated hashCode and equals take into account all non-transient fields.<br>
|
||||
* Static fields are skipped (no getter or setter, and they are not included in toString, equals, hashCode, or the constructor).
|
||||
* <p>
|
||||
* {@code toString}, {@code equals}, and {@code hashCode} use the deepX variants in the
|
||||
* {@code java.util.Arrays} utility class. Therefore, if your class has arrays that contain themselves,
|
||||
* these methods will just loop endlessly until the inevitable {@code StackOverflowError}. This behaviour
|
||||
* is no different from {@code java.util.ArrayList}, though.
|
||||
* @see lombok.Getter
|
||||
* @see Wither
|
||||
* @see lombok.RequiredArgsConstructor
|
||||
* @see lombok.ToString
|
||||
* @see lombok.EqualsAndHashCode
|
||||
* @see lombok.Data
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -31,6 +31,10 @@ import lombok.AccessLevel;
|
||||
/**
|
||||
* Put on any field to make lombok build a 'wither' - a withX method which produces a clone of this object (except for 1 field which gets a new value).
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/experimental/Wither.html">the project lombok features page for @Wither</a>.
|
||||
* <p>
|
||||
* Even though it is not listed, this annotation also has the {@code onParam} and {@code onMethod} parameter. See the full documentation for more details.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* private @Wither final int foo;
|
||||
@@ -43,9 +47,6 @@ import lombok.AccessLevel;
|
||||
* return this.foo == foo ? this : new SELF_TYPE(otherField1, otherField2, foo);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* If any method named {@code withFoo} (case insensitive) exists, regardless of return type or parameters,
|
||||
* no method is generated, and instead a compiler warning is emitted.
|
||||
* <p>
|
||||
* This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have
|
||||
* a {@code Wither} annotation have the annotation.
|
||||
|
||||
@@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @CommonsLog
|
||||
|
||||
Vendored
+3
@@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @Log
|
||||
|
||||
+3
@@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @Log4j
|
||||
|
||||
+3
@@ -27,6 +27,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @Slf4j
|
||||
|
||||
+3
@@ -27,6 +27,9 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/Log.html">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @XSlf4j
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Project Lombok Authors.
|
||||
* Copyright (C) 2010-2012 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
|
||||
@@ -25,7 +25,9 @@ package lombok;
|
||||
* Use {@code val} as the type of any local variable declaration (even in a for-each statement), and the type will be inferred from the initializing expression.
|
||||
* For example: {@code val x = 10.0;} will infer {@code double}, and {@code val y = new ArrayList<String>();} will infer {@code ArrayList<String>}. The local variable
|
||||
* will also be made final.
|
||||
*
|
||||
* Note that this is an interface because {@code val x = 10;} will be desugared to {@code @val int x = 10;}
|
||||
* <p>
|
||||
* Note that this is an annotation type because {@code val x = 10;} will be desugared to {@code @val final int x = 10;}
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="http://projectlombok.org/features/val.html">the project lombok features page for @val</a>.
|
||||
*/
|
||||
public @interface val {}
|
||||
Reference in new issue
Block a user