@Override public boolean isCollection() { return ((getComponentType() != null) && (Collection.class.isAssignableFrom(getAssignmentClass()))); }
@Override public final int hashCode() { int hash = getType().hashCode(); GenericType<?> definingType = getDefiningType(); if (definingType != null) { hash = hash * 31 + definingType.hashCode(); } return hash; }
@Override public boolean isMap() { return (getKeyType() != null); }
@Override public boolean isAssignableFrom(GenericType<?> subType) { Class<?> upperBound = getRetrievalClass(); Class<?> subTypeUpperBound = subType.getRetrievalClass(); Class<?> lowerBound = getAssignmentClass(); Class<?> subTypeLowerBound = subType.getAssignmentClass(); if ((lowerBound != upperBound) || (subTypeLowerBound != subTypeUpperBound)) { int argCount = getTypeArgumentCount(); if (argCount > 0) { if (upperBound == subTypeUpperBound) { GenericType<?> typeArgument = getTypeArgument(argIndex); GenericType<?> subTypeArgument = subType.getTypeArgument(argIndex); Type resolvedType = resolveTypeVariable(typeVariable, this); Type resolvedSubType = resolveTypeVariable(typeVariable, subType); GenericType<?> resolvedGenericType = create(resolvedType); GenericType<?> resolvedGenericSubType = create(resolvedSubType); if (!resolvedGenericType.isAssignableFrom(resolvedGenericSubType)) { return false;
List<Type> hierarchy = getGenericDeclarations(declaringClass, declaringType.getRetrievalClass()); if (hierarchy != null) { TypeVariable<?> currentVariable = typeVariable; ParameterizedType pt = (ParameterizedType) hierarchyType; Type[] typeArguments = pt.getActualTypeArguments(); int variableIndex = getDeclarationIndex(currentVariable); if (variableIndex >= 0) { Type typeArgument = typeArguments[variableIndex]; GenericType<?> definingType = ((AbstractGenericType<?>) declaringType).getDefiningType(); if (definingType != null) { return resolveTypeVariable(typeVariable, definingType, declaringClass);
@Override public final String toString() { Type type = getType(); Class<?> upperBound = getRetrievalClass(); if (upperBound == type) { if (upperBound.isArray()) { return upperBound.getComponentType().getName() + "[]"; } else { return upperBound.getName(); } } else { return type.toString(); } }
@Override public final boolean equals(Object other) { if (other == null) { return false; } if (other == this) { return true; } if (other instanceof AbstractGenericType<?>) { AbstractGenericType<?> otherType = (AbstractGenericType<?>) other; if (getType().equals(otherType.getType())) { GenericType<?> definingType = getDefiningType(); if (definingType == null) { return (otherType.getDefiningType() == null); } else { return (definingType.equals(otherType.getDefiningType())); } } } return false; }