public boolean inherits(AnnotationType type) { if (equals(type)) return true; if (superType != null && superType.inherits(type)) return true; return false; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Annotation)) return false; Annotation that = (Annotation) o; if (!type.equals(that.type)) return false; if (spanNode != null ? !spanNode.equals(that.spanNode) : that.spanNode != null) return false; if (value != null ? !value.equals(that.value) : that.value != null) return false; return true; }
/** * Register a new annotation type. WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code. * * @param type the type to register * @throws IllegalArgumentException if a type is already registered with this name or this id, and it is non-equal to the argument. */ public void register(AnnotationType type) { if (idMap.containsKey(type.getId()) || nameMap.containsKey(type.getName())) { AnnotationType idType = idMap.get(type.getId()); AnnotationType nameType = nameMap.get(type.getName()); if (type.equals(idType) && type.equals(nameType)) { //it's the same one being re-registered, we're OK! return; } throw new IllegalArgumentException("A type is already registered with this name or this id."); } idMap.put(type.getId(), type); nameMap.put(type.getName(), type); }