Java Reference
In-Depth Information
Supposeyoudecidetoreplace Stub 's id() , dueDate() ,and developer() ele-
ments with a single String value() element whose string specifies comma-sep-
arated ID, due date, and developer name values. Listing 3-45 shows you two ways to
initialize value .
Listing 3-45. Initializing each Stub instance's value() element
public class Deck
{
@Stub(value = "1,12/21/2012,unassigned")
public void shuffle()
{
}
@Stub("2,12/21/2012,unassigned")
public Card[] deal(int cards)
{
return null;
}
}
Listing 3-45 reveals special treatment for the value() element. When it is an an-
notationtype'sonlyelement,youcanomit value() 'snameand = fromtheinitializer.I
usedthisfacttospecify @SuppressWarnings("deprecation") in Listing3-40 .
Using Meta-Annotations in Annotation Type Declarations
Eachofthe Override , Deprecated ,and SuppressWarnings annotationtypes
is itself annotated with meta-annotations (annotations that annotate annotation types).
For example, Listing 3-46 shows you that the SuppressWarnings annotation type
is annotated with two meta-annotations.
Listing 3-46. The annotated SuppressWarnings type declaration
@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR,
LOCAL_VARIABLE})
@Retention(RetentionPolicy.SOURCE)
public @interface SuppressWarnings
 
Search WWH ::




Custom Search