List of usage examples for org.eclipse.jdt.internal.compiler.lookup ElementValuePair getValue
public Object getValue()
Object[] for member value of array type. From source file:com.android.build.gradle.tasks.annotations.Extractor.java
License:Apache License
@SuppressWarnings("unused") static boolean hasSourceRetention(@NonNull AnnotationBinding a) { if (new String(a.getAnnotationType().readableName()).equals("java.lang.annotation.Retention")) { ElementValuePair[] pairs = a.getElementValuePairs(); if (pairs == null || pairs.length != 1) { warning("Expected exactly one parameter passed to @Retention"); return false; }/* ww w .java2s. c o m*/ ElementValuePair pair = pairs[0]; Object value = pair.getValue(); if (value instanceof FieldBinding) { FieldBinding field = (FieldBinding) value; if ("SOURCE".equals(new String(field.readableName()))) { return true; } } } return false; }
From source file:com.codenvy.ide.ext.java.server.TypeBindingConvector.java
License:Open Source License
private static JsonElement toJsonElementValuePair(ElementValuePair pair) { JsonObject object = new JsonObject(); object.add("name", pair.getName() == null ? JsonNull.INSTANCE : new JsonPrimitive(new String(pair.getName()))); object.add("value", toJsonDefaultValue(pair.getValue())); return object; }
From source file:com.google.gwt.dev.javac.JdtUtil.java
License:Apache License
public static String getAnnotationParameterString(AnnotationBinding a, String paramName) { if (a != null) { for (ElementValuePair maybeValue : a.getElementValuePairs()) { if (maybeValue.getValue() instanceof StringConstant && paramName.equals(String.valueOf(maybeValue.getName()))) { return ((StringConstant) maybeValue.getValue()).stringValue(); }/*from ww w . j a v a 2 s.c om*/ } } return null; }
From source file:com.google.gwt.dev.javac.JdtUtil.java
License:Apache License
public static boolean getAnnotationParameterBoolean(AnnotationBinding a, String paramName) { if (a != null) { for (ElementValuePair maybeValue : a.getElementValuePairs()) { if (maybeValue.getValue() instanceof BooleanConstant && paramName.equals(String.valueOf(maybeValue.getName()))) { return ((BooleanConstant) maybeValue.getValue()).booleanValue(); }//from w w w. j a v a2s. co m } } return false; }
From source file:com.google.gwt.dev.javac.JdtUtil.java
License:Apache License
public static TypeBinding getAnnotationParameterTypeBinding(AnnotationBinding a, String paramName) { if (a != null) { for (ElementValuePair maybeValue : a.getElementValuePairs()) { if (maybeValue.getValue() instanceof Class && paramName.equals(String.valueOf(maybeValue.getName()))) { return (TypeBinding) maybeValue.getValue(); }//ww w. j a va 2 s. c o m } } return null; }
From source file:com.google.gwt.dev.javac.JdtUtil.java
License:Apache License
public static TypeBinding[] getAnnotationParameterTypeBindingArray(AnnotationBinding annotationBinding, String paramName) {//from ww w.j a va 2 s.c o m if (annotationBinding == null) { return null; } for (ElementValuePair maybeValue : annotationBinding.getElementValuePairs()) { Object value = maybeValue.getValue(); if (!paramName.equals(String.valueOf(maybeValue.getName()))) { continue; } if (value instanceof Object[]) { Object[] values = (Object[]) value; TypeBinding bindings[] = new TypeBinding[values.length]; System.arraycopy(values, 0, bindings, 0, values.length); return bindings; } assert value instanceof TypeBinding; return new TypeBinding[] { (TypeBinding) value }; } return null; }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTAnnotation.java
License:Open Source License
@Override public Object getValue(String fieldName) { if (values == null) { values = new HashMap<String, Object>(); ElementValuePair[] annotationVaues = annotation.getElementValuePairs(); for (ElementValuePair annotationValue : annotationVaues) { String name = new String(annotationValue.getName()); Object value = convertValue(annotationValue.getValue()); values.put(name, value);/* w w w.j av a2 s . c o m*/ } } return values.get(fieldName); }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.JDTAnnotation.java
License:Open Source License
public JDTAnnotation(AnnotationBinding annotation) { values = new HashMap<String, Object>(); ElementValuePair[] annotationVaues = annotation.getElementValuePairs(); for (ElementValuePair annotationValue : annotationVaues) { String name = new String(annotationValue.getName()); MethodBinding elementMethod = annotationValue.getMethodBinding(); Object value = null;/* w w w . j a va2s. co m*/ if (elementMethod != null) { value = convertValue(annotationValue.getMethodBinding().returnType, annotationValue.getValue()); } else { value = JDTType.UNKNOWN_TYPE; } values.put(name, value); } }