Reputation: 8670
Which is the objective of the method getDefaultValue() in class java.lang.reflect.Method ?, can someone point me out a situation where this method is useful ?.
The description from the API of Method does not say a lot to me, I do not get what is the "annotation member represented by this Method instance
" :
Returns the default value for the annotation member represented by this Method instance. If the member is of a primitive type, an instance of the corresponding wrapper type is returned. Returns null if no default is associated with the member, or if the method instance does not represent a declared member of an annotation type.
Upvotes: 6
Views: 978
Reputation: 5267
Annotations have their "attributes" as methods. For instance:
public @interface Example {
public String stringValue() default "string default value";
public int intValue() default 10;
}
The getDefaultValue()
of a Method from an annotation returns the default value of an annotation "attribute" defined this way. In the example, the default value of the Method stringValue()
is "string default value"
.
Upvotes: 12