/** * {@inheritDoc} */ @SuppressFBWarnings(value = "EC_UNRELATED_CLASS_AND_INTERFACE", justification = "Fits equality contract for type definitions") public boolean represents(java.lang.reflect.Type type) { return equals(Sort.describe(type)); }
/** * {@inheritDoc} */ public AnnotationList getInheritedAnnotations() { Generic superClass = getSuperClass(); AnnotationList declaredAnnotations = getDeclaredAnnotations(); if (superClass == null) { return declaredAnnotations; } else { Set<TypeDescription> annotationTypes = new HashSet<TypeDescription>(); for (AnnotationDescription annotationDescription : declaredAnnotations) { annotationTypes.add(annotationDescription.getAnnotationType()); } return new AnnotationList.Explicit(CompoundList.of(declaredAnnotations, superClass.asErasure().getInheritedAnnotations().inherited(annotationTypes))); } }
/** * {@inheritDoc} */ public String getActualName() { if (isArray()) { TypeDescription typeDescription = this; int dimensions = 0; do { dimensions++; typeDescription = typeDescription.getComponentType(); } while (typeDescription.isArray()); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(typeDescription.getActualName()); for (int i = 0; i < dimensions; i++) { stringBuilder.append("[]"); } return stringBuilder.toString(); } else { return getName(); } }
if ((represents(Class.class) && value instanceof TypeDescription) || (value instanceof AnnotationDescription && ((AnnotationDescription) value).getAnnotationType().equals(this)) || (value instanceof EnumerationDescription && ((EnumerationDescription) value).getEnumerationType().equals(this)) || (represents(String.class) && value instanceof String) || (represents(boolean.class) && value instanceof Boolean) || (represents(byte.class) && value instanceof Byte) || (represents(short.class) && value instanceof Short) || (represents(char.class) && value instanceof Character) || (represents(int.class) && value instanceof Integer) || (represents(long.class) && value instanceof Long) || (represents(float.class) && value instanceof Float) || (represents(double.class) && value instanceof Double) || (represents(String[].class) && value instanceof String[]) || (represents(boolean[].class) && value instanceof boolean[]) || (represents(byte[].class) && value instanceof byte[]) || (represents(short[].class) && value instanceof short[]) || (represents(char[].class) && value instanceof char[]) || (represents(int[].class) && value instanceof int[]) || (represents(long[].class) && value instanceof long[]) || (represents(float[].class) && value instanceof float[]) || (represents(double[].class) && value instanceof double[]) || (represents(Class[].class) && value instanceof TypeDescription[])) { return true; } else if (isAssignableTo(Annotation[].class) && value instanceof AnnotationDescription[]) { for (AnnotationDescription annotationDescription : (AnnotationDescription[]) value) { if (!annotationDescription.getAnnotationType().equals(getComponentType())) { return false; } else if (isAssignableTo(Enum[].class) && value instanceof EnumerationDescription[]) {
SignatureWriter signatureWriter = new SignatureWriter(); boolean generic = false; for (Generic typeVariable : getTypeVariables()) { signatureWriter.visitFormalTypeParameter(typeVariable.getSymbol()); for (Generic upperBound : typeVariable.getUpperBounds()) { Generic superClass = getSuperClass(); for (Generic interfaceType : getInterfaces()) { interfaceType.accept(new Generic.Visitor.ForSignatureVisitor(signatureWriter.visitInterface())); generic = generic || !interfaceType.getSort().isNonGeneric();
/** * {@inheritDoc} */ public int getActualModifiers(boolean superFlag) { int actualModifiers = getModifiers() | (getDeclaredAnnotations().isAnnotationPresent(Deprecated.class) ? Opcodes.ACC_DEPRECATED : EMPTY_MASK); if (isPrivate()) { actualModifiers = actualModifiers & ~(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC); } else if (isProtected()) { actualModifiers = actualModifiers & ~(Opcodes.ACC_PROTECTED | Opcodes.ACC_STATIC) | Opcodes.ACC_PUBLIC; } else { actualModifiers = actualModifiers & ~Opcodes.ACC_STATIC; } return superFlag ? (actualModifiers | Opcodes.ACC_SUPER) : actualModifiers; }
@Override public String toString() { return (isPrimitive() ? "" : (isInterface() ? "interface" : "class") + " ") + getName(); }
@Override public int hashCode() { return getName().hashCode(); }
/** * {@inheritDoc} */ public boolean isNestMateOf(TypeDescription typeDescription) { return getNestHost().equals(typeDescription.getNestHost()); }
/** * {@inheritDoc} */ public boolean isGenerified() { if (!getTypeVariables().isEmpty()) { return true; } else if (isStatic()) { return false; } TypeDescription declaringType = getDeclaringType(); return declaringType != null && declaringType.isGenerified(); }
/** * {@inheritDoc} */ public TypeVariableSource getEnclosingSource() { MethodDescription enclosingMethod = getEnclosingMethod(); return enclosingMethod == null ? (isStatic() ? TypeVariableSource.UNDEFINED : getEnclosingType()) // Top-level classes (non-static) have no enclosing type. : enclosingMethod; }
/** * {@inheritDoc} */ public boolean isMemberType() { return !isLocalType() && !isAnonymousType() && getDeclaringType() != null; }
/** * {@inheritDoc} */ public boolean isNestedClass() { return getDeclaringType() != null; }
/** * {@inheritDoc} */ public int getInnerClassCount() { if (isStatic()) { return 0; } TypeDescription declaringType = getDeclaringType(); return declaringType == null ? 0 : declaringType.getInnerClassCount() + 1; }
/** * {@inheritDoc} */ public boolean isAnnotationReturnType() { return isPrimitive() || represents(String.class) || (isAssignableTo(Enum.class) && !represents(Enum.class)) || (isAssignableTo(Annotation.class) && !represents(Annotation.class)) || represents(Class.class) || (isArray() && !getComponentType().isArray() && getComponentType().isAnnotationReturnType()); }
/** * {@inheritDoc} */ public boolean isVisibleTo(TypeDescription typeDescription) { return isPrimitive() || (isArray() ? getComponentType().isVisibleTo(typeDescription) : isPublic() || isProtected() || isSamePackage(typeDescription)/* || equals(typeDescription.asErasure()) */); }
/** * {@inheritDoc} */ public String getTypeName() { return getName(); }
/** * {@inheritDoc} */ public boolean isNestHost() { return equals(getNestHost()); }
@Override public boolean equals(Object other) { if (this == other) { return true; } else if (!(other instanceof TypeDefinition)) { return false; } TypeDefinition typeDefinition = (TypeDefinition) other; return typeDefinition.getSort().isNonGeneric() && getName().equals(typeDefinition.asErasure().getName()); }
/** * {@inheritDoc} */ public String getInternalName() { return getName().replace('.', '/'); }