29
29
import org .springframework .util .Assert ;
30
30
31
31
/**
32
- * An enumeration of Apache Geode {@literal gemfire.properties}.
32
+ * An Enum ( enumeration) of Apache Geode {@literal gemfire.properties}.
33
33
*
34
34
* @author John Blum
35
35
* @see org.apache.geode.distributed.ConfigurationProperties
@@ -157,6 +157,15 @@ public enum GemFireProperties {
157
157
USER_COMMAND_PACKAGES (ConfigurationProperties .USER_COMMAND_PACKAGES , String .class ),
158
158
VALIDATE_SERIALIZABLE_OBJECTS (ConfigurationProperties .VALIDATE_SERIALIZABLE_OBJECTS , Boolean .class , false );
159
159
160
+ /**
161
+ * Factory method used to get a {@link GemFireProperties} enumerated value for the given {@link String property name}.
162
+ *
163
+ * @param propertyName {@link String name} of the {@link GemFireProperties} enumerated value to return.
164
+ * @return a {@link GemFireProperties} enumerated value for the given {@link String property name}.
165
+ * @throws IllegalArgumentException if a {@link GemFireProperties} enumerated value cannot be found
166
+ * for the given {@link String property name}.
167
+ * @see #values()
168
+ */
160
169
public static @ NonNull GemFireProperties from (@ Nullable String propertyName ) {
161
170
162
171
return Arrays .stream (values ())
@@ -213,18 +222,53 @@ private static boolean equals(@Nullable GemFireProperties property, @Nullable St
213
222
this .defaultValue = defaultValue ;
214
223
}
215
224
225
+ /**
226
+ * Gets this property's {@link Object default value}.
227
+ *
228
+ * @return this property's {@link Object default value}.
229
+ * @see java.lang.Object
230
+ */
216
231
public @ Nullable Object getDefaultValue () {
217
232
return this .defaultValue != null ? this .defaultValue : DEFAULT_PROPERTY_VALUE ;
218
233
}
219
234
235
+ /**
236
+ * Gets this property's {@link Object default value} as a {@link String}.
237
+ *
238
+ * @return this property's {@link Object default value} as a {@link String}. If this property's
239
+ * {@link Object default value} is {@literal null}, then this method return the {@literal "null"} {@link String}.
240
+ * @see #getDefaultValue()
241
+ * @see java.lang.String
242
+ */
220
243
public @ NonNull String getDefaultValueAsString () {
221
244
return String .valueOf (getDefaultValue ());
222
245
}
223
246
247
+ /**
248
+ * Gets this property's {@link Object default value} converted to the property's declared {@link Class type}.
249
+ *
250
+ * @param <T> declared {@link Class type} of this property.
251
+ * @return this property's {@link Object default value} converted to the property's declared {@link Class type}.
252
+ * @throws IllegalArgumentException if this property's {@link Object default value} cannot be converted to
253
+ * the property's declared {@link Class type}.
254
+ * @see #getDefaultValueAsType(Class)
255
+ * @see #getType()
256
+ */
224
257
public @ NonNull <T > T getDefaultValueAsType () {
225
258
return getDefaultValueAsType (getType ());
226
259
}
227
260
261
+ /**
262
+ * Gets this property's {@link Object default value} converted to the given {@link Class type}.
263
+ *
264
+ * @param <T> desired {@link Class type} for this property's {@link Object default value}.
265
+ * @param type {@link Class type} to convert the property's {@link Object default value} to.
266
+ * @return this property's {@link Object default value} converted to an instance of the given {@link Class type}.
267
+ * @throws IllegalArgumentException if this property's {@link Object default value} cannot be converted to
268
+ * an instance of the given {@link Class type}.
269
+ * @see #getDefaultValue()
270
+ * @see #getType()
271
+ */
228
272
@ SuppressWarnings ("unchecked" )
229
273
public <T > T getDefaultValueAsType (Class <?> type ) {
230
274
@@ -233,21 +277,36 @@ public <T> T getDefaultValueAsType(Class<?> type) {
233
277
Class <?> defaultValueType = nullSafeType (defaultValue , getType ());
234
278
235
279
if (this .conversionService .canConvert (defaultValueType , type )) {
236
- return (T ) this .conversionService .convert (getDefaultValue () , type );
280
+ return (T ) this .conversionService .convert (defaultValue , type );
237
281
}
238
282
239
283
throw newIllegalArgumentException ("Cannot convert value [%s] from type [%s] to type [%s]" ,
240
284
defaultValue , defaultValueType , type );
241
285
}
242
286
287
+ /**
288
+ * Gets the {@link String name} of this property.
289
+ *
290
+ * @return the {@link String name} of this property.
291
+ * @see java.lang.String
292
+ */
243
293
public @ NonNull String getName () {
244
294
return this .propertyName ;
245
295
}
246
296
297
+ /**
298
+ * Gets the declared {@link Class type} of this property.
299
+ *
300
+ * @return the declared {@link Class type} of this property.
301
+ * @see java.lang.Class
302
+ */
247
303
public @ NonNull Class <?> getType () {
248
304
return this .propertyType != null ? this .propertyType : DEFAULT_PROPERTY_TYPE ;
249
305
}
250
306
307
+ /**
308
+ * @inheritDoc
309
+ */
251
310
@ Override
252
311
public String toString () {
253
312
return getName ();
0 commit comments