Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 1998, 2013 Oracle and/or its affiliates. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 which accompanies this distribution. The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse Distribution License is available at http://www.eclipse.org/org/documents/edl-v10.php. Contributors: 08/10/2009-2.0 Guy Pelletier - 267391: JPA 2.0 implement/extend/use an APT tooling library for MetaModel API canonical classes /
 
 package org.eclipse.persistence.internal.jpa.modelgen.visitors;
 
 import java.util.List;
 import java.util.Set;
 
 
An annotation element visitor.

Author(s):
Guy Pelletier
Since:
EclipseLink 1.2
 
 public class AnnotationValueVisitor<R, P> extends AbstractAnnotationValueVisitor6<ObjectObject> {
    
INTERNAL:
 
     public AnnotationValueVisitor() {}
    
    
INTERNAL: Visits an annotation mirror. Kicks off the building of the metadata annotation.
 
     @Override
     public Object visitAnnotation(AnnotationMirror annotationMirrorObject arg1) {
         // Set the name of the annotation.
         MetadataAnnotation annotation = new MetadataAnnotation();
         annotation.setName(annotationMirror.getAnnotationType().toString());
 
         // Process the values.
         Set<? extends ExecutableElementkeys = annotationMirror.getElementValues().keySet();
         
         for (ExecutableElement annotationElement : keys) {
             AnnotationValue annotationValue = annotationMirror.getElementValues().get(annotationElement);
             String attribute = annotationElement.getSimpleName().toString();
             Object attributeValue = annotationValue.accept(thisarg1);
             annotation.addAttribute(attributeattributeValue);
         }
 
         return annotation;
     }

    
INTERNAL: e.g. joinColumns={

JoinColumn:
name="ID1", referencedColumnName="ID"),
JoinColumn:
name="ID2", referencedColumnName="ID")}
 
     @Override
     public Object visitArray(List<? extends AnnotationValueannotationValuesObject arg1) {
         ArrayList<Objectvalues = new ArrayList<Object>();
 
         for (AnnotationValue annotationValue : annotationValues) {
             values.add(annotationValue.accept(thisarg1));
         }
         
         return values.toArray();
     }

    
INTERNAL: e.g. shared=true
 
     @Override
     public Object visitBoolean(boolean boolObject arg1) {
         return Boolean.valueOf(bool);
     }

    
INTERNAL: e.g. byte=13
 
     @Override
     public Object visitByte(byte bObject arg1) {
         return Byte.valueOf(b);
     }

    
INTERNAL: e.g. type='c'
    @Override
    public Object visitChar(char cObject arg1) {
        return Character.valueOf(c);
    }

    
INTERNAL: e.g. size=6.02E23
    @Override
    public Object visitDouble(double dObject arg1) {
        return Double.valueOf(d);
    }

    
INTERNAL: e.g. fetch=LAZY
    @Override
    public Object visitEnumConstant(VariableElement variableArgumentObject arg1) {
        return variableArgument.getSimpleName().toString();
    }

    
INTERNAL: e.g. size=6.02e23f
    @Override
    public Object visitFloat(float fObject arg1) {
        return Float.valueOf(f);
    }

    
INTERNAL: e.g. size=730
    @Override
    public Object visitInt(int iObject arg1) {
        return Integer.valueOf(i);
    }

    
INTERNAL: e.g. size=9223372036854775807
    @Override
    public Object visitLong(long lObject arg1) {
        return Long.valueOf(l);
    }

    
INTERNAL: e.g. size=7
    @Override
    public Object visitShort(short sObject arg1) {
        return Short.valueOf(s);
    }

    
INTERNAL: e.g. name="findAllSQLEmployees"
    @Override
    public Object visitString(String strObject arg1) {
        return str;
    }

    
INTERNAL: e.g. targetEntity=Item.class
    @Override
    public Object visitType(TypeMirror typeMirrorObject arg1) {
        return typeMirror.toString();
    }
New to GrepCode? Check out our FAQ X