Java Code Examples for java.lang.annotation.RetentionPolicy#CLASS

The following examples show how to use java.lang.annotation.RetentionPolicy#CLASS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationsTestBase.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected RetentionPolicy getRetentionPolicy(String name) {
    if (name.contains("Visible")) {
        return RetentionPolicy.RUNTIME;
    } else if (name.contains("Invisible")) {
        return RetentionPolicy.CLASS;
    }
    throw new IllegalArgumentException(name);
}
 
Example 2
Source File: AnnotationDef.java    From annotation-tools with MIT License 5 votes vote down vote up
/**
 * The retention policy for annotations of this type.
 * If non-null, this is called a "top-level" annotation definition.
 * It may be null for annotations that are used only as a field of other
 * annotations.
 *
 * @return the retention policy for annotations of this type
 */
public @Nullable RetentionPolicy retention() {
    if (tlAnnotationsHere.contains(Annotations.aRetentionClass)) {
        return RetentionPolicy.CLASS;
    } else if (tlAnnotationsHere.contains(Annotations.aRetentionRuntime)) {
        return RetentionPolicy.RUNTIME;
    } else if (tlAnnotationsHere.contains(Annotations.aRetentionSource)) {
        return RetentionPolicy.SOURCE;
    } else {
        return null;
    }
}
 
Example 3
Source File: AnnotationUsageCache.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor
 *
 * @param aAnnotationClass
 *        The annotation class to store the existence of. It must have the
 *        {@link RetentionPolicy#RUNTIME} to be usable within this class!
 */
public AnnotationUsageCache (@Nonnull final Class <? extends Annotation> aAnnotationClass)
{
  ValueEnforcer.notNull (aAnnotationClass, "AnnotationClass");

  // Check retention policy
  final Retention aRetention = aAnnotationClass.getAnnotation (Retention.class);
  final RetentionPolicy eRetentionPolicy = aRetention == null ? RetentionPolicy.CLASS : aRetention.value ();
  if (eRetentionPolicy != RetentionPolicy.RUNTIME)
    throw new IllegalArgumentException ("RetentionPolicy must be of type RUNTIME to be used within this cache. The current value ist " +
                                        eRetentionPolicy);

  // Save to members
  m_aAnnotationClass = aAnnotationClass;
}
 
Example 4
Source File: AdviceTest.java    From byte-buddy with Apache License 2.0 5 votes vote down vote up
@Advice.OnMethodEnter
@Advice.OnMethodExit
private static void advice(@Custom Object value) {
    if (value != Object.class && value != RetentionPolicy.CLASS && value != null) {
        throw new AssertionError();
    }
}
 
Example 5
Source File: GetterEncloser.java    From immutables with Apache License 2.0 5 votes vote down vote up
@GetterAnnotation(policy = RetentionPolicy.CLASS,
    string = "\n\"",
    type = Object.class,
    value = {@InnerAnnotation, @InnerAnnotation},
    bval = Byte.MIN_VALUE, dval = Double.POSITIVE_INFINITY,
    ival = Integer.MAX_VALUE,
    fval = Float.NaN,
    blval = true,
    cval = 'j')
@Path("/ef")
@Value.Auxiliary
boolean ef();