Package java.lang.annotation

Examples of java.lang.annotation.Annotation


    public void testPopulateClassName() throws Exception {
        final AnnotationData data = new AnnotationData();

        Class expected;
        String method;
        Annotation annotation;

        // Null Annotation
        expected = InvalidateAssignCache.class;
        method = "populateClassName01";
        try {
View Full Code Here


     * @param whenQualifier When this event occurred (e.g.: {@link PhaseListener#beforePhase(PhaseEvent)} or
     *                      {@link PhaseListener#afterPhase(PhaseEvent)})
     * @param event         The JSF PhaseEvent to be propagated
     */
    private void handlePhase(final AnnotationLiteral<?> whenQualifier, final PhaseEvent event) {
        Annotation phaseQualifier = null;

        if (PhaseId.RESTORE_VIEW.equals(event.getPhaseId())) {
            phaseQualifier = RESTORE_VIEW;
        } else if (PhaseId.PROCESS_VALIDATIONS.equals(event.getPhaseId())) {
            phaseQualifier = PROCESS_VALIDATIONS;
View Full Code Here

    generateBasicClass(aa);
    checkClass(defineClass("C", cw.toByteArray()));
  }

  protected void checkClass(Class c) throws Exception {
    Annotation a = c.getAnnotation(Deprecated.class);
    assertNotNull(a);
  }
View Full Code Here

    generateBasicClass(aa);
    checkClass(defineClass("C", cw.toByteArray()));
  }

  protected void checkClass(Class c) throws Exception {
    Annotation a = c.getAnnotation(Deprecated.class);
    assertNull(a);
  }
View Full Code Here

        if (paramAnnotationArrays != null && paramAnnotationArrays.length > 0) {
            for (int ix = 0; ix < paramAnnotationArrays.length; ix++) {
                final Annotation[] paramAnnotations = paramAnnotationArrays[ix];
                if (paramAnnotations != null && paramAnnotations.length > 0) {
                    for (int jx = 0; jx < paramAnnotations.length; jx++) {
                        final Annotation paramAnnotation = paramAnnotations[jx];
                        if (ParameterDataUpdateContent.class.equals(paramAnnotation.annotationType())) {
                            if (foundIndex >= 0) {
                                throw new InvalidParameterException(String.format(
                                        "Multiple annotations of type [%s] found on method [%s]",
                                        ParameterDataUpdateContent.class.getName(),
                                        targetMethod.getName()
View Full Code Here

            return;
        }

        final Annotation[][] paramAnnotationArrays = targetMethod.getParameterAnnotations();
        int foundIndex = Integer.MIN_VALUE;
        Annotation foundAnnotation = null;

        if (paramAnnotationArrays != null && paramAnnotationArrays.length > 0) {
            for (int ix = 0; ix < paramAnnotationArrays.length; ix++) {
                final Annotation[] paramAnnotations = paramAnnotationArrays[ix];
                if (paramAnnotations != null && paramAnnotations.length > 0) {
                    for (int jx = 0; jx < paramAnnotations.length; jx++) {
                        final Annotation paramAnnotation = paramAnnotations[jx];
                        if (ParameterValueKeyProvider.class.equals(paramAnnotation.annotationType())) {
                            if (foundIndex >= 0) {
                                throw new InvalidParameterException(String.format(
                                        "Multiple annotations of type [%s] found on method [%s]",
                                        ParameterValueKeyProvider.class.getName(),
                                        targetMethod.getName()
View Full Code Here

        return annotations.toArray(new Annotation[annotations.size()]);
    }

    public <A extends Annotation> A getClassAnnotation(Class<A> anntype, Class type, Locatable loc)
    {
        Annotation proxy = getAnnotationHandler(anntype, type);
        if (proxy != null)
        {
           return (A)proxy;
        }
        return LocatableAnnotation.create(((Class<?>)type).getAnnotation(anntype), loc);
View Full Code Here

        return baseReader.getClassValue(a, name);
    }

    public <A extends Annotation> A getFieldAnnotation(Class<A> type, Field field, Locatable loc)
    {
        Annotation proxy = getProxy(type, field);
        if (proxy != null)
        {
            return (A) proxy;
        }
        return LocatableAnnotation.create(field.getAnnotation(type), loc);
View Full Code Here

        return LocatableAnnotation.create(field.getAnnotation(type), loc);
    }

    public <A extends Annotation> A getMethodAnnotation(Class<A> type, Method method, Locatable loc)
    {
        Annotation proxy = getProxy(type, method);
        if (proxy != null)
        {
            return (A) proxy;
        }
        return LocatableAnnotation.create(method.getAnnotation(type), loc);
View Full Code Here

    {
        List<Annotation> annotations = new ArrayList<Annotation>();

        if (ammd.getPersistenceModifier() == FieldPersistenceModifier.NONE)
        {
            Annotation annotation = getAnnotationHandler(XmlTransient.class);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlAttribute"))
        {
            Annotation annotation = getAnnotation(XmlAttribute.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlElement"))
        {
            Annotation annotation = getAnnotation(XmlElement.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlElementRef"))
        {
            Annotation annotation = getAnnotation(XmlElementRef.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlElementWrapper"))
        {
            Annotation annotation = getAnnotation(XmlElementWrapper.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlIDREF"))
        {
            Annotation annotation = getAnnotation(XmlIDREF.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.hasExtension("XmlID"))
        {
            Annotation annotation = getAnnotation(XmlID.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
        else if (ammd.isPrimaryKey())
        {
            // All PK fields should have XmlID
            // Note : JAXB has a limitation of 1 XmlID field per class!!
            if (ammd.getAbstractClassMetaData().getNoOfPrimaryKeyMembers() > 1)
            {
                // TODO Remove this when we remove the limit on PK field numbers
                throw new NucleusException("Class " + ammd.getAbstractClassMetaData().getFullClassName() + " has more than 1 primary key field - not valid for JAXB");
            }
            if (ammd.getAbstractClassMetaData().getNoOfPrimaryKeyMembers() == 1)
            {
                if (!String.class.isAssignableFrom(ammd.getType()))
                {
                    // TODO Remove this when we remove the limit on PK field types
                    throw new NucleusException("Class " + ammd.getAbstractClassMetaData().getFullClassName() +
                        " has primary-key field " + ammd.getName() + " but this is not a String type - not valid for JAXB");
                }
                Annotation annotation = getAnnotation(XmlID.class, ammd, member, loc);
                if (annotation != null)
                {
                    annotations.add(annotation);
                }
            }
        }
        else if (ammd.getEmbeddedMetaData() == null && ammd.getRelationType(clr) != Relation.NONE)
        {
            // Relation and not embedded so give it an XmlIDREF so we just refer to the other object(s)
            Annotation annotation = getAnnotation(XmlIDREF.class, ammd, member, loc);
            if (annotation != null)
            {
                annotations.add(annotation);
            }
        }
View Full Code Here

TOP

Related Classes of java.lang.annotation.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.