org.apache.commons.attributes

Class 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 { ... }
 
Since:
2.1

Field Summary

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

Constructor Summary

Target(int flags)
Creates a new target attribute.

Method Summary

int
getFlags()
Returns an int that is the bitwise or of the allowed target flags.

Field Details

ALL

public static final int ALL
Indicates that the attribute can be applied to any program element.
Field Value:
127
Since:
2.1

CLASS

public static final int CLASS
Indicates that the attribute can be applied to a class or interface.
Field Value:
1
Since:
2.1

CONSTRUCTOR

public static final int CONSTRUCTOR
Indicates that the attribute can be applied to a constructor.
Field Value:
8
Since:
2.1

CONSTRUCTOR_PARAMETER

public static final int CONSTRUCTOR_PARAMETER
Indicates that the attribute can be applied to a constructor parameter.
Field Value:
32
Since:
2.1

FIELD

public static final int FIELD
Indicates that the attribute can be applied to a field.
Field Value:
2
Since:
2.1

METHOD

public static final int METHOD
Indicates that the attribute can be applied to a method.
Field Value:
4
Since:
2.1

METHOD_PARAMETER

public static final int METHOD_PARAMETER
Indicates that the attribute can be applied to a method parameter.
Field Value:
16
Since:
2.1

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.
Field Value:
48
Since:
2.1

RETURN

public static final int RETURN
Indicates that the attribute can be applied to a method return value.
Field Value:
64
Since:
2.1

flags

private final int flags

Constructor Details

Target

public Target(int flags)
Creates a new target attribute.
Parameters:
flags - a bitwise or of flags indicating the allowed targets.
Since:
2.1

Method Details

getFlags

public int getFlags()
Returns an int that is the bitwise or of the allowed target flags.
Since:
2.1