@Override public AnnotationMap asAnnotationMap() { return new AnnotationMap(); }
static AnnotationMap _emptyAnnotationMap() { return new AnnotationMap(); }
public static AnnotationMap of(Class<?> type, Annotation value) { HashMap<Class<?>,Annotation> ann = new HashMap<>(4); ann.put(type, value); return new AnnotationMap(ann); }
@Override public AnnotationMap asAnnotationMap() { AnnotationMap result = new AnnotationMap(); for (Annotation ann : _annotations.values()) { result.add(ann); } return result; }
@Override public Annotations asAnnotations() { if (_annotations.size() == 2) { Iterator<Map.Entry<Class<?>,Annotation>> it = _annotations.entrySet().iterator(); Map.Entry<Class<?>,Annotation> en1 = it.next(), en2 = it.next(); return new TwoAnnotations(en1.getKey(), en1.getValue(), en2.getKey(), en2.getValue()); } return new AnnotationMap(_annotations); }
/** * Method called to override a method parameter annotation, * usually due to a mix-in * annotation masking or overriding an annotation 'real' method * has. */ public final void addOrOverrideParam(int paramIndex, Annotation a) { AnnotationMap old = _paramAnnotations[paramIndex]; if (old == null) { old = new AnnotationMap(); _paramAnnotations[paramIndex] = old; } old.add(a); }
public static AnnotationMap merge(AnnotationMap primary, AnnotationMap secondary) { if (primary == null || primary._annotations == null || primary._annotations.isEmpty()) { return secondary; } if (secondary == null || secondary._annotations == null || secondary._annotations.isEmpty()) { return primary; } HashMap<Class<?>,Annotation> annotations = new HashMap<Class<?>,Annotation>(); // add secondary ones first for (Annotation ann : secondary._annotations.values()) { annotations.put(ann.annotationType(), ann); } // to be overridden by primary ones for (Annotation ann : primary._annotations.values()) { annotations.put(ann.annotationType(), ann); } return new AnnotationMap(annotations); }
protected AnnotationMap annotations() { AnnotationMap am = _annotations; if (am == null) { Annotation[] raw = _rawAnnotations; if (raw == null || raw.length == 0) { am = NO_ANNOTATIONS; } else { am = new AnnotationMap(); for (Annotation a : raw) { am.add(a); } } _annotations = am; } return am; } }
protected AnnotationMap annotations() { AnnotationMap am = _annotations; if (am == null) { Annotation[] raw = _rawAnnotations; if (raw == null || raw.length == 0) { am = NO_ANNOTATIONS; } else { am = new AnnotationMap(); for (Annotation a : raw) { am.add(a); } } _annotations = am; } return am; } }
public static AnnotationMap of(Class<?> type, Annotation value) { HashMap<Class<?>,Annotation> ann = new HashMap<>(4); ann.put(type, value); return new AnnotationMap(ann); }
protected AnnotationMap _collectRelevantAnnotations(Annotation[] anns) { AnnotationMap annMap = new AnnotationMap(); _addAnnotationsIfNotPresent(annMap, anns); return annMap; }
private static AnnotationMap buildAnnotationMap(Annotation[] declaredAnnotations) { AnnotationMap annotationMap = new AnnotationMap(); for (Annotation annotation : declaredAnnotations) { annotationMap.add(annotation); } return annotationMap; }
@Override public Annotations asAnnotations() { if (_annotations.size() == 2) { Iterator<Map.Entry<Class<?>,Annotation>> it = _annotations.entrySet().iterator(); Map.Entry<Class<?>,Annotation> en1 = it.next(), en2 = it.next(); return new TwoAnnotations(en1.getKey(), en1.getValue(), en2.getKey(), en2.getValue()); } return new AnnotationMap(_annotations); }
@Override public AnnotationMap asAnnotationMap() { AnnotationMap result = new AnnotationMap(); for (Annotation ann : _annotations.values()) { result.add(ann); } return result; }
protected AnnotationMap _collectRelevantAnnotations(Annotation[] anns) { AnnotationMap annMap = new AnnotationMap(); _addAnnotationsIfNotPresent(annMap, anns); return annMap; }
private static AnnotationMap annotationMap(Annotation [] annotations){ AnnotationMap annotationMap = new AnnotationMap(); if(annotations == null){ return annotationMap; } for(Annotation annotation:annotations){ annotationMap.add(annotation); } return annotationMap; }
protected AnnotationMap _collectRelevantAnnotations(Annotation[] anns) { return _addAnnotationsIfNotPresent(new AnnotationMap(), anns); }
protected AnnotationMap _collectRelevantAnnotations(Annotation[] anns) { return _addAnnotationsIfNotPresent(new AnnotationMap(), anns); }
private AbstractType getTSTypeForClass(AnnotatedMember member) { TypeBindings bindings = new TypeBindings(TypeFactory.defaultInstance(), member.getDeclaringClass()); BeanProperty prop = new BeanProperty.Std(member.getName(), member.getType(bindings), NO_NAME, new AnnotationMap(), member, false); try { return getTSTypeForProperty(prop); } catch (JsonMappingException e) { throw new RuntimeException(e); } }
private void addMethod(Method method) { FunctionType function = new FunctionType(); AnnotatedMethod annotMethod = new AnnotatedMethod(null, method, new AnnotationMap(), null); function.setResultType(getTSTypeForClass(annotMethod)); for (int i = 0; i < annotMethod.getParameterCount(); i++) { AnnotatedParameter param = annotMethod.getParameter(i); String name = "param" + i; function.getParameters().put(name, getTSTypeForClass(param)); } this.type.getMethods().put(method.getName(), function); }