public List<MethodMetadata> getMethods() { final List<MethodMetadata> result = new ArrayList<MethodMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final MethodMetadata method : current.getDeclaredMethods()) { result.add(method); } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }
public FieldMetadata getField(final JavaSymbolName fieldName) { Validate.notNull(fieldName, "Field name required"); MemberHoldingTypeDetails current = this; while (current != null) { final FieldMetadata result = current.getDeclaredField(fieldName); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
public MethodMetadata getMethod(final JavaSymbolName methodName) { Validate.notNull(methodName, "Method name required"); MemberHoldingTypeDetails current = this; while (current != null) { final MethodMetadata result = MemberFindingUtils.getDeclaredMethod(current, methodName); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
public AnnotationMetadata getTypeAnnotation(final JavaType annotationType) { Validate.notNull(annotationType, "Annotation type required"); IdentifiableAnnotatedJavaStructure current = this; while (current != null) { final AnnotationMetadata result = current.getAnnotation(annotationType); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; } }
/** * Determines if the presented class (or any of its superclasses) implements * the target interface. * * @param clazz the cid to search * @param interfaceTarget the interface to locate * @return true if the class or any of its superclasses contains the * specified interface */ protected boolean isImplementing(final ClassOrInterfaceTypeDetails clazz, final JavaType interfaceTarget) { if (clazz.getImplementsTypes().contains(interfaceTarget)) { return true; } if (clazz.getSuperclass() != null) { return isImplementing(clazz.getSuperclass(), interfaceTarget); } return false; }
public MethodMetadata getMethod(final JavaSymbolName methodName, List<JavaType> parameters) { Validate.notNull(methodName, "Method name required"); if (parameters == null) { parameters = new ArrayList<JavaType>(); } MemberHoldingTypeDetails current = this; while (current != null) { final MethodMetadata result = MemberFindingUtils.getDeclaredMethod(current, methodName, parameters); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
private void init(final ClassOrInterfaceTypeDetails existing) { name = existing.getName(); physicalTypeCategory = existing.getPhysicalTypeCategory(); if (existing.getSuperclass() != null) { superclass = new ClassOrInterfaceTypeDetailsBuilder(existing.getSuperclass()); } enumConstants.addAll(existing.getEnumConstants()); registeredImports.clear(); registeredImports.addAll(existing.getRegisteredImports()); }
public List<FieldMetadata> getFieldsWithAnnotation(final JavaType annotation) { Validate.notNull(annotation, "Annotation required"); final List<FieldMetadata> result = new ArrayList<FieldMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final FieldMetadata field : current.getDeclaredFields()) { if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), annotation) != null) { // Found the annotation on this field result.add(field); } } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }
/** * Looks up the given type's inheritance hierarchy for metadata of the given * type, starting with the given type's parent and going upwards until the * first such instance is found (i.e. lower level metadata takes priority * over higher level metadata) * * @param <T> the type of metadata to look for * @param child the child type whose parents to search (required) * @return <code>null</code> if there is no such metadata */ @SuppressWarnings("unchecked") protected <T extends MetadataItem> T getParentMetadata(final ClassOrInterfaceTypeDetails child) { T parentMetadata = null; ClassOrInterfaceTypeDetails superCid = child.getSuperclass(); while (parentMetadata == null && superCid != null) { final String superCidPhysicalTypeIdentifier = superCid.getDeclaredByMetadataId(); final LogicalPath path = PhysicalTypeIdentifier.getPath(superCidPhysicalTypeIdentifier); final String superCidLocalIdentifier = createLocalIdentifier(superCid.getName(), path); parentMetadata = (T) getMetadataService().get(superCidLocalIdentifier); superCid = superCid.getSuperclass(); } return parentMetadata; // Could be null }
public List<FieldMetadata> getToStringFields( final PhysicalTypeMetadata governorPhysicalTypeMetadata, final List<FieldMetadata> declaredFields) { ClassOrInterfaceTypeDetails superclass = governorPhysicalTypeMetadata.getMemberHoldingTypeDetails().getSuperclass(); List<FieldMetadata> toStringFields = new ArrayList<FieldMetadata>(); if (superclass != null && superclass != JavaType.OBJECT) { List<FieldMetadata> superclassFields = getMemberDetailsScanner().getMemberDetails(this.getClass().getName(), superclass) .getFields(); for (FieldMetadata field : declaredFields) { boolean alreadyInSuperclass = false; for (FieldMetadata superclassField : superclassFields) { if (superclassField.getDeclaredByMetadataId().equals(field.getDeclaredByMetadataId()) && superclassField.getFieldName().equals(field.getFieldName())) { alreadyInSuperclass = true; break; } } if (!alreadyInSuperclass) { toStringFields.add(field); } } } else { toStringFields.addAll(declaredFields); } return toStringFields; }
while (cid != null) { cidHierarchy.add(0, cid); // Note to the top of the list cid = cid.getSuperclass();
&& details.getExtendsTypes().size() == 1) { if (details.getSuperclass() != null) { final String superclassId = details.getSuperclass().getDeclaredByMetadataId(); metadataDependencyRegistry.registerDependency(superclassId, result.getId()); } else {
public List<MethodMetadata> getMethods() { final List<MethodMetadata> result = new ArrayList<MethodMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final MethodMetadata method : current.getDeclaredMethods()) { result.add(method); } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }
public MethodMetadata getMethod(final JavaSymbolName methodName) { Validate.notNull(methodName, "Method name required"); MemberHoldingTypeDetails current = this; while (current != null) { final MethodMetadata result = MemberFindingUtils.getDeclaredMethod(current, methodName); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
public FieldMetadata getField(final JavaSymbolName fieldName) { Validate.notNull(fieldName, "Field name required"); MemberHoldingTypeDetails current = this; while (current != null) { final FieldMetadata result = current.getDeclaredField(fieldName); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
public AnnotationMetadata getTypeAnnotation(final JavaType annotationType) { Validate.notNull(annotationType, "Annotation type required"); IdentifiableAnnotatedJavaStructure current = this; while (current != null) { final AnnotationMetadata result = current.getAnnotation(annotationType); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; } }
public MethodMetadata getMethod(final JavaSymbolName methodName, List<JavaType> parameters) { Validate.notNull(methodName, "Method name required"); if (parameters == null) { parameters = new ArrayList<JavaType>(); } MemberHoldingTypeDetails current = this; while (current != null) { final MethodMetadata result = MemberFindingUtils.getDeclaredMethod(current, methodName, parameters); if (result != null) { return result; } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return null; }
/** * Determines if the presented class (or any of its superclasses) implements * the target interface. * * @param clazz the cid to search * @param interfaceTarget the interface to locate * @return true if the class or any of its superclasses contains the * specified interface */ protected boolean isImplementing(final ClassOrInterfaceTypeDetails clazz, final JavaType interfaceTarget) { if (clazz.getImplementsTypes().contains(interfaceTarget)) { return true; } if (clazz.getSuperclass() != null) { return isImplementing(clazz.getSuperclass(), interfaceTarget); } return false; }
private void init(final ClassOrInterfaceTypeDetails existing) { name = existing.getName(); physicalTypeCategory = existing.getPhysicalTypeCategory(); if (existing.getSuperclass() != null) { superclass = new ClassOrInterfaceTypeDetailsBuilder(existing.getSuperclass()); } enumConstants.addAll(existing.getEnumConstants()); registeredImports.clear(); registeredImports.addAll(existing.getRegisteredImports()); }
public List<FieldMetadata> getFieldsWithAnnotation(final JavaType annotation) { Validate.notNull(annotation, "Annotation required"); final List<FieldMetadata> result = new ArrayList<FieldMetadata>(); MemberHoldingTypeDetails current = this; while (current != null) { for (final FieldMetadata field : current.getDeclaredFields()) { if (MemberFindingUtils.getAnnotationOfType(field.getAnnotations(), annotation) != null) { // Found the annotation on this field result.add(field); } } if (current instanceof ClassOrInterfaceTypeDetails) { current = ((ClassOrInterfaceTypeDetails) current).getSuperclass(); } else { current = null; } } return result; }