org.apache.commons.attributes
Class Target
java.lang.Object
org.apache.commons.attributes.Target
public class Target
extends java.lang.Object
Attribute indicating what elements an attribute may be applied to.
This is checked at runtime. If the attribute is absent, it defaults
to
Target.ALL
.
This attribute is intended to be used with attribute classes:
/**
* MyAttribute can only be applied to classes and fields, not methods.
* @@Target(Target.CLASS | Target.FIELD)
*/
public class MyAttribute { ... }
static int | ALL - Indicates that the attribute can be applied to any program element.
|
static int | CLASS - Indicates that the attribute can be applied to a class or interface.
|
static int | CONSTRUCTOR - Indicates that the attribute can be applied to a constructor.
|
static int | CONSTRUCTOR_PARAMETER - Indicates that the attribute can be applied to a constructor parameter.
|
static int | FIELD - Indicates that the attribute can be applied to a field.
|
static int | METHOD - Indicates that the attribute can be applied to a method.
|
static int | METHOD_PARAMETER - Indicates that the attribute can be applied to a method parameter.
|
static int | PARAMETER - Indicates that the attribute can be applied to a parameter of a method or a constructor.
|
static int | RETURN - Indicates that the attribute can be applied to a method return value.
|
private int | flags
|
Target(int flags) - Creates a new target attribute.
|
int | getFlags() - Returns an
int that is the bitwise or of the allowed target flags.
|
ALL
public static final int ALL
Indicates that the attribute can be applied to any program element.
CLASS
public static final int CLASS
Indicates that the attribute can be applied to a class or interface.
CONSTRUCTOR
public static final int CONSTRUCTOR
Indicates that the attribute can be applied to a constructor.
CONSTRUCTOR_PARAMETER
public static final int CONSTRUCTOR_PARAMETER
Indicates that the attribute can be applied to a constructor parameter.
FIELD
public static final int FIELD
Indicates that the attribute can be applied to a field.
METHOD
public static final int METHOD
Indicates that the attribute can be applied to a method.
METHOD_PARAMETER
public static final int METHOD_PARAMETER
Indicates that the attribute can be applied to a method parameter.
PARAMETER
public static final int PARAMETER
Indicates that the attribute can be applied to a parameter of a method or a constructor.
It is equal to METHOD_PARAMETER | CONSTRUCTOR_PARAMETER
.
RETURN
public static final int RETURN
Indicates that the attribute can be applied to a method return value.
flags
private final int flags
Target
public Target(int flags)
Creates a new target attribute.
flags
- a bitwise or of flags indicating the allowed targets.
getFlags
public int getFlags()
Returns an int
that is the bitwise or of the allowed target flags.