alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Attributes example source code file (Target.java)

This example Commons Attributes source code file (Target.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Attributes tags/keywords

all, class, constructor, constructor, constructor_parameter, constructor_parameter, field, method, method_parameter, method_parameter, parameter, return, return, target

The Commons Attributes Target.java source code

package org.apache.commons.attributes;

/**
 * Attribute indicating what elements an attribute may be applied to.
 * This is checked at runtime. If the attribute is absent, it defaults
 * to {@link Target#ALL Target.ALL}.
 *
 * <p>This attribute is intended to be used with attribute classes:
 * 
 * <pre>
 * /**
 *  * MyAttribute can only be applied to classes and fields, not methods.
 *  * @@Target(Target.CLASS | Target.FIELD)
 *  */
 * public class MyAttribute { ... }
 * </code>
* * @since 2.1 */ public class Target { /** * Indicates that the attribute can be applied to a class or interface. * * @since 2.1 */ public static final int CLASS = 1; /** * Indicates that the attribute can be applied to a field. * * @since 2.1 */ public static final int FIELD = 2; /** * Indicates that the attribute can be applied to a method. * * @since 2.1 */ public static final int METHOD = 4; /** * Indicates that the attribute can be applied to a constructor. * * @since 2.1 */ public static final int CONSTRUCTOR = 8; /** * Indicates that the attribute can be applied to a method parameter. * * @since 2.1 */ public static final int METHOD_PARAMETER = 16; /** * Indicates that the attribute can be applied to a constructor parameter. * * @since 2.1 */ public static final int CONSTRUCTOR_PARAMETER = 32; /** * Indicates that the attribute can be applied to a method return value. * * @since 2.1 */ public static final int RETURN = 64; /** * Indicates that the attribute can be applied to a parameter of a method or a constructor. * It is equal to <code>METHOD_PARAMETER | CONSTRUCTOR_PARAMETER. * * @since 2.1 */ public static final int PARAMETER = METHOD_PARAMETER | CONSTRUCTOR_PARAMETER; /** * Indicates that the attribute can be applied to any program element. * * @since 2.1 */ public static final int ALL = CLASS | FIELD | METHOD | CONSTRUCTOR | PARAMETER | RETURN; private final int flags; /** * Creates a new target attribute. * * @param flags a bitwise or of flags indicating the allowed targets. * @since 2.1 */ public Target (int flags) { this.flags = flags; } /** * Returns an <code>int that is the bitwise or of the allowed target flags. * * @since 2.1 */ public int getFlags () { return flags; } }

Other Commons Attributes examples (source code examples)

Here is a short list of links related to this Commons Attributes Target.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.