|
4 | 4 | import java.lang.annotation.Retention;
|
5 | 5 | import java.lang.annotation.RetentionPolicy;
|
6 | 6 | import java.lang.annotation.Target;
|
7 |
| -import java.util.function.Supplier; |
8 | 7 |
|
9 | 8 | /**
|
10 | 9 | * <h3>Marker for parameter methods</h3>
|
|
56 | 55 | * <h3>Optional custom mapper</h3>
|
57 | 56 | *
|
58 | 57 | * <p>
|
59 |
| - * The mapper is a {@link java.util.function.Supplier Supplier} that returns a |
60 |
| - * {@link java.util.function.Function Function<String, X>}. |
| 58 | + * The mapper is a either a {@link java.util.function.Function Function<String, X>} |
| 59 | + * or a {@link java.util.function.Supplier Supplier} that returns such a function. |
61 | 60 | * The return value {@code X} is called the <em>mapper type</em>.
|
62 | 61 | * The parameter method must return {@code X}, or {@code Optional<X>} if the
|
63 | 62 | * parameter is {@link #optional()}, or {@code List<X>} if the parameter is
|
|
69 | 68 | * </p>
|
70 | 69 | *
|
71 | 70 | * <pre>{@code
|
72 |
| - * class PositiveNumberMapper implements Supplier<Function<String, Integer>> { |
73 |
| - * |
74 |
| - * public Function<String, Integer> get() { |
75 |
| - * return s -> { |
76 |
| - * Integer r = Integer.valueOf(s); |
77 |
| - * if (r <= 0) { |
78 |
| - * throw new IllegalArgumentException("Positive number expected"); |
79 |
| - * } |
80 |
| - * return r; |
| 71 | + * class PositiveNumberMapper implements Function<String, Integer> { |
| 72 | + * |
| 73 | + * public Integer apply(String s) { |
| 74 | + * Integer r = Integer.valueOf(s); |
| 75 | + * if (r <= 0) { |
| 76 | + * throw new IllegalArgumentException("Positive number expected"); |
81 | 77 | * }
|
| 78 | + * return r; |
82 | 79 | * }
|
83 | 80 | * }
|
84 | 81 | * }</pre>
|
85 | 82 | *
|
86 |
| - * @return an optional mapper class |
| 83 | + * @return a mapper class |
87 | 84 | */
|
88 |
| - Class<?> mappedBy() default Supplier.class; |
| 85 | + Class<?> mappedBy() default Object.class; |
89 | 86 |
|
90 | 87 | /**
|
91 | 88 | * <h3>Optional custom collector</h3>
|
92 | 89 | *
|
93 | 90 | * <p>
|
94 |
| - * The supplier must return a {@link java.util.stream.Collector Collector<M, ?, X>} |
95 |
| - * where {@code X} is the parameter type, and {@code M} is the <em>mapper type</em>. |
| 91 | + * This is either a {@link java.util.stream.Collector Collector<M, ?, X>} |
| 92 | + * where {@code X} is the parameter type and {@code M} is the <em>mapper type</em>, |
| 93 | + * or a {@link java.util.function.Supplier Supplier} that returns such a collector. |
96 | 94 | * </p>
|
97 | 95 | *
|
98 | 96 | * <p>
|
99 | 97 | * For example, the following collector creates a {@code Set}:
|
100 | 98 | * </p>
|
101 | 99 | *
|
102 | 100 | * <pre>{@code
|
103 |
| - * class ToSetCollector<E> implements Supplier<Collector<E, ?, Set<E>>> { |
| 101 | + * class ToSetCollector<E>; implements Supplier<Collector<E, ?, Set<E>>> { |
104 | 102 | *
|
105 |
| - * public Collector<E, ?, Set<E>> get() { |
| 103 | + * public Collector<E, ?, Set<E>> get() { |
106 | 104 | * return Collectors.toSet();
|
107 | 105 | * }
|
108 | 106 | * }
|
109 | 107 | * }</pre>
|
110 | 108 | *
|
111 |
| - * @return an optional collector class |
| 109 | + * @return an collector class |
112 | 110 | */
|
113 |
| - Class<?> collectedBy() default Supplier.class; |
| 111 | + Class<?> collectedBy() default Object.class; |
114 | 112 |
|
115 | 113 | /**
|
116 |
| - * <p>Declares this parameter repeatable.</p> |
| 114 | + * <p>Declares this parameter as repeatable.</p> |
117 | 115 | *
|
118 | 116 | * @return true if this parameter is repeatable
|
119 | 117 | */
|
120 | 118 | boolean repeatable() default false;
|
121 | 119 |
|
122 | 120 | /**
|
123 |
| - * <p>Declares this parameter optional.</p> |
| 121 | + * <p>Declares this parameter as optional.</p> |
124 | 122 | *
|
125 | 123 | * <p>
|
126 | 124 | * <em>Note:</em>
|
|
135 | 133 |
|
136 | 134 | /**
|
137 | 135 | * <p>Declares a parameter that doesn't take an argument.
|
138 |
| - * For example, the following shell command contains a flag:</p> |
| 136 | + * For example, the following shell command contains the flag {@code -l}:</p> |
139 | 137 | *
|
140 | 138 | * <pre>{@code
|
141 | 139 | * ls -l
|
|
159 | 157 | */
|
160 | 158 | String bundleKey() default "";
|
161 | 159 | }
|
| 160 | + |
0 commit comments