public ElementValuePair(char[] name, Expression expression, MethodBinding binding) { this(name, ElementValuePair.getValue(expression), binding); }
public static void setMethodBindings(ReferenceBinding type, ElementValuePair[] pairs) { // set the method bindings of each element value pair for (int i = pairs.length; --i >= 0;) { ElementValuePair pair = pairs[i]; MethodBinding[] methods = type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) pair.setMethodBinding(methods[0]); } }
@Override public boolean isDeprecated() { MethodBinding methodBinding = this.internalPair.getMethodBinding(); return methodBinding == null ? false : methodBinding.isDeprecated(); }
public ElementValuePair[] getElementValuePairs() { if (this.env != null) { if (this.typeUnresolved) { getAnnotationType(); // resolve the annotation type } // resolve method binding and value type (if unresolved) for each pair for (int i = this.pairs.length; --i >= 0;) { ElementValuePair pair = this.pairs[i]; MethodBinding[] methods = this.type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) { pair.setMethodBinding(methods[0]); } // else silently leave a null there Object value = pair.getValue(); if (value instanceof UnresolvedReferenceBinding) { pair.setValue(((UnresolvedReferenceBinding) value). resolve(this.env, false)); // no parameterized types in annotation values } // do nothing for UnresolvedAnnotationBinding-s, since their // content is only accessed through get* methods } this.env = null; } return this.pairs; } }
/** * @return all the members of this annotation mirror that have explicit values. * Default values are not included. */ @Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues() { if (this._binding == null) { return Collections.emptyMap(); } ElementValuePair[] pairs = _binding.getElementValuePairs(); Map<ExecutableElement, AnnotationValue> valueMap = new LinkedHashMap<>(pairs.length); for (ElementValuePair pair : pairs) { MethodBinding method = pair.getMethodBinding(); if (method == null) { // ideally we should be able to create a fake ExecutableElementImpl continue; } ExecutableElement e = new ExecutableElementImpl(_env, method); AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method); valueMap.put(e, v); } return Collections.unmodifiableMap(valueMap); }
Object value = mb.getDefaultValue(); if (value != null) { defaultValues.put(name, new ElementValuePair(mb.selector, value, mb));
char[] internalName() { return this.internalPair == null ? null : this.internalPair.getName(); }
public <A extends java.lang.annotation.Annotation> CtAnnotation<A> getTypeCtAnnotation(AnnotationBinding annotationBinding) { CtAnnotation<A> a = factory.Core().createAnnotation(); CtTypeReference<A> t = references.getTypeReference(annotationBinding.getAnnotationType()); a.setAnnotationType(t); for (ElementValuePair valuePair : annotationBinding.getElementValuePairs()) { a.addValue(String.valueOf(valuePair.getName()), buildValuePairAnnotation(valuePair.getValue())); } return a; }
public ElementValuePair[] getElementValuePairs() { if (this.env != null) { if (this.typeUnresolved) { resolve(); } // resolve method binding and value type (if unresolved) for each pair for (int i = this.pairs.length; --i >= 0;) { ElementValuePair pair = this.pairs[i]; MethodBinding[] methods = this.type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) { pair.setMethodBinding(methods[0]); } // else silently leave a null there Object value = pair.getValue(); if (value instanceof UnresolvedReferenceBinding) { pair.setValue(((UnresolvedReferenceBinding) value). resolve(this.env, false)); // no parameterized types in annotation values } // do nothing for UnresolvedAnnotationBinding-s, since their // content is only accessed through get* methods } this.env = null; } return this.pairs; } }
/** * @return all the members of this annotation mirror that have explicit values. * Default values are not included. */ public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues() { if (this._binding == null) { return Collections.emptyMap(); } ElementValuePair[] pairs = _binding.getElementValuePairs(); Map<ExecutableElement, AnnotationValue> valueMap = new LinkedHashMap<ExecutableElement, AnnotationValue>(pairs.length); for (ElementValuePair pair : pairs) { MethodBinding method = pair.getMethodBinding(); if (method == null) { // ideally we should be able to create a fake ExecutableElementImpl continue; } ExecutableElement e = new ExecutableElementImpl(_env, method); AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method); valueMap.put(e, v); } return Collections.unmodifiableMap(valueMap); }
static AnnotationBinding createAnnotation(IBinaryAnnotation annotationInfo, LookupEnvironment env, char[][][] missingTypeNames) { // temporary debug for Bug 532176 - [10] NPE during reconcile if (annotationInfo instanceof AnnotationInfo) { RuntimeException ex = ((AnnotationInfo) annotationInfo).exceptionDuringDecode; if (ex != null) new IllegalStateException("Accessing annotation with decode error", ex).printStackTrace(); //$NON-NLS-1$ } //-- IBinaryElementValuePair[] binaryPairs = annotationInfo.getElementValuePairs(); int length = binaryPairs == null ? 0 : binaryPairs.length; ElementValuePair[] pairs = length == 0 ? Binding.NO_ELEMENT_VALUE_PAIRS : new ElementValuePair[length]; for (int i = 0; i < length; i++) pairs[i] = new ElementValuePair(binaryPairs[i].getName(), convertMemberValue(binaryPairs[i].getValue(), env, missingTypeNames, false), null); char[] typeName = annotationInfo.getTypeName(); LookupEnvironment env2 = annotationInfo.isExternalAnnotation() ? env.root : env; ReferenceBinding annotationType = env2.getTypeFromConstantPoolName(typeName, 1, typeName.length - 1, false, missingTypeNames); return env2.createUnresolvedAnnotation(annotationType, pairs); }
@Override public String getName() { if (this.internalPair == null) return null; final char[] membername = this.internalPair.getName(); return membername == null ? null : new String(membername); }
public ElementValuePair[] getElementValuePairs() { if (this.env != null) { if (this.typeUnresolved) { resolve(); } // resolve method binding and value type (if unresolved) for each pair for (int i = this.pairs.length; --i >= 0;) { ElementValuePair pair = this.pairs[i]; MethodBinding[] methods = this.type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) { pair.setMethodBinding(methods[0]); } // else silently leave a null there Object value = pair.getValue(); if (value instanceof UnresolvedReferenceBinding) { pair.setValue(((UnresolvedReferenceBinding) value). resolve(this.env, false)); // no parameterized types in annotation values } // do nothing for UnresolvedAnnotationBinding-s, since their // content is only accessed through get* methods } this.env = null; } return this.pairs; } }
/** * @return all the members of this annotation mirror that have explicit values. * Default values are not included. */ @Override public Map<? extends ExecutableElement, ? extends AnnotationValue> getElementValues() { if (this._binding == null) { return Collections.emptyMap(); } ElementValuePair[] pairs = _binding.getElementValuePairs(); Map<ExecutableElement, AnnotationValue> valueMap = new LinkedHashMap<>(pairs.length); for (ElementValuePair pair : pairs) { MethodBinding method = pair.getMethodBinding(); if (method == null) { // ideally we should be able to create a fake ExecutableElementImpl continue; } ExecutableElement e = new ExecutableElementImpl(_env, method); AnnotationValue v = new AnnotationMemberValue(_env, pair.getValue(), method); valueMap.put(e, v); } return Collections.unmodifiableMap(valueMap); }
public static void setMethodBindings(ReferenceBinding type, ElementValuePair[] pairs) { // set the method bindings of each element value pair for (int i = pairs.length; --i >= 0;) { ElementValuePair pair = pairs[i]; MethodBinding[] methods = type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) pair.setMethodBinding(methods[0]); } }
public ElementValuePair(char[] name, Expression expression, MethodBinding binding) { this(name, ElementValuePair.getValue(expression), binding); }
static AnnotationBinding createAnnotation(IBinaryAnnotation annotationInfo, LookupEnvironment env, char[][][] missingTypeNames) { IBinaryElementValuePair[] binaryPairs = annotationInfo.getElementValuePairs(); int length = binaryPairs == null ? 0 : binaryPairs.length; ElementValuePair[] pairs = length == 0 ? Binding.NO_ELEMENT_VALUE_PAIRS : new ElementValuePair[length]; for (int i = 0; i < length; i++) pairs[i] = new ElementValuePair(binaryPairs[i].getName(), convertMemberValue(binaryPairs[i].getValue(), env, missingTypeNames, false), null); char[] typeName = annotationInfo.getTypeName(); ReferenceBinding annotationType = env.getTypeFromConstantPoolName(typeName, 1, typeName.length - 1, false, missingTypeNames); return env.createUnresolvedAnnotation(annotationType, pairs); }
public String getName() { if (this.internalPair == null) return null; final char[] membername = this.internalPair.getName(); return membername == null ? null : new String(membername); }
public boolean isDeprecated() { MethodBinding methodBinding = this.internalPair.getMethodBinding(); return methodBinding == null ? false : methodBinding.isDeprecated(); }
public ElementValuePair[] getElementValuePairs() { if (this.env != null) { if (this.typeUnresolved) { getAnnotationType(); // resolve the annotation type } // resolve method binding and value type (if unresolved) for each pair for (int i = this.pairs.length; --i >= 0;) { ElementValuePair pair = this.pairs[i]; MethodBinding[] methods = this.type.getMethods(pair.getName()); // there should be exactly one since the type is an annotation type. if (methods != null && methods.length == 1) { pair.setMethodBinding(methods[0]); } // else silently leave a null there Object value = pair.getValue(); if (value instanceof UnresolvedReferenceBinding) { pair.setValue(((UnresolvedReferenceBinding) value). resolve(this.env, false)); // no parameterized types in annotation values } // do nothing for UnresolvedAnnotationBinding-s, since their // content is only accessed through get* methods } this.env = null; } return this.pairs; } }