1 package org.pojomatic.annotations;
2
3 import static java.lang.annotation.ElementType.FIELD;
4 import static java.lang.annotation.ElementType.METHOD;
5 import static java.lang.annotation.RetentionPolicy.RUNTIME;
6
7 import java.lang.annotation.Documented;
8 import java.lang.annotation.Retention;
9 import java.lang.annotation.Target;
10
11 import org.pojomatic.Pojomatic;
12
13 /**
14 * Marks a property of a class to be used by {@link Pojomatic}
15 * @see PojomaticPolicy
16 */
17 @Target({FIELD, METHOD})
18 @Retention(RUNTIME)
19 @Documented
20 public @interface Property {
21
22 /**
23 * Which sets of {@link Pojomatic} operations ({@code equals}, {@code hashCode} and
24 * {@code toString}) should use a property.
25 * @return Which operations should use the annotated property
26 */
27 public PojomaticPolicy policy() default PojomaticPolicy.DEFAULT;
28
29 /**
30 * The name used to identify the property in the standard {@code toString} representation. If
31 * empty, the following algorithm is used to determine the name. For a property referenced by
32 * field, the name of the field is used. For a property referenced by a method whose name is of
33 * the form {@code getSomeField}, the name {@code someField} will be used. For a boolean property
34 * referenced by a method whose name is of the form {@code isSomeField}, the name
35 * {@code someField} will be used. For any other property referenced by a method, the name of
36 * the method is used.
37 *
38 * @return the name used to identify the property in the standard {@code toString} representation.
39 */
40 public String name() default "";
41 }