mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 03:24:58 +00:00
Clean ups.
This commit is contained in:
parent
6240c11f22
commit
1c42dfb057
@ -32,5 +32,5 @@
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface EqualsExclude {
|
public @interface EqualsExclude {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,5 @@
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface HashCodeExclude {
|
public @interface HashCodeExclude {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
@ -31,5 +31,5 @@
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface ToStringExclude {
|
public @interface ToStringExclude {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
@ -36,5 +36,5 @@
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface ToStringSummary {
|
public @interface ToStringSummary {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
@ -150,12 +150,12 @@ private static final class ParameterizedTypeImpl implements ParameterizedType {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param raw type
|
* @param rawClass type
|
||||||
* @param useOwner owner type to use, if any
|
* @param useOwner owner type to use, if any
|
||||||
* @param typeArguments formal type arguments
|
* @param typeArguments formal type arguments
|
||||||
*/
|
*/
|
||||||
private ParameterizedTypeImpl(final Class<?> raw, final Type useOwner, final Type[] typeArguments) {
|
private ParameterizedTypeImpl(final Class<?> rawClass, final Type useOwner, final Type[] typeArguments) {
|
||||||
this.raw = raw;
|
this.raw = rawClass;
|
||||||
this.useOwner = useOwner;
|
this.useOwner = useOwner;
|
||||||
this.typeArguments = Arrays.copyOf(typeArguments, typeArguments.length, Type[].class);
|
this.typeArguments = Arrays.copyOf(typeArguments, typeArguments.length, Type[].class);
|
||||||
}
|
}
|
||||||
@ -482,17 +482,18 @@ private static boolean isAssignable(final Type type, final ParameterizedType toP
|
|||||||
/**
|
/**
|
||||||
* Look up {@code var} in {@code typeVarAssigns} <em>transitively</em>,
|
* Look up {@code var} in {@code typeVarAssigns} <em>transitively</em>,
|
||||||
* i.e. keep looking until the value found is <em>not</em> a type variable.
|
* i.e. keep looking until the value found is <em>not</em> a type variable.
|
||||||
* @param var the type variable to look up
|
* @param typeVariable the type variable to look up
|
||||||
* @param typeVarAssigns the map used for the look up
|
* @param typeVarAssigns the map used for the look up
|
||||||
* @return Type or {@code null} if some variable was not in the map
|
* @return Type or {@code null} if some variable was not in the map
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static Type unrollVariableAssignments(TypeVariable<?> var, final Map<TypeVariable<?>, Type> typeVarAssigns) {
|
private static Type unrollVariableAssignments(TypeVariable<?> typeVariable,
|
||||||
|
final Map<TypeVariable<?>, Type> typeVarAssigns) {
|
||||||
Type result;
|
Type result;
|
||||||
do {
|
do {
|
||||||
result = typeVarAssigns.get(var);
|
result = typeVarAssigns.get(typeVariable);
|
||||||
if (result instanceof TypeVariable<?> && !result.equals(var)) {
|
if (result instanceof TypeVariable<?> && !result.equals(typeVariable)) {
|
||||||
var = (TypeVariable<?>) result;
|
typeVariable = (TypeVariable<?>) result;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1344,8 +1345,8 @@ public static boolean isArrayType(final Type type) {
|
|||||||
*/
|
*/
|
||||||
public static Type getArrayComponentType(final Type type) {
|
public static Type getArrayComponentType(final Type type) {
|
||||||
if (type instanceof Class<?>) {
|
if (type instanceof Class<?>) {
|
||||||
final Class<?> clazz = (Class<?>) type;
|
final Class<?> cls = (Class<?>) type;
|
||||||
return clazz.isArray() ? clazz.getComponentType() : null;
|
return cls.isArray() ? cls.getComponentType() : null;
|
||||||
}
|
}
|
||||||
if (type instanceof GenericArrayType) {
|
if (type instanceof GenericArrayType) {
|
||||||
return ((GenericArrayType) type).getGenericComponentType();
|
return ((GenericArrayType) type).getGenericComponentType();
|
||||||
@ -1451,76 +1452,78 @@ public static boolean containsTypeVariables(final Type type) {
|
|||||||
/**
|
/**
|
||||||
* Create a parameterized type instance.
|
* Create a parameterized type instance.
|
||||||
*
|
*
|
||||||
* @param raw the raw class to create a parameterized type instance for
|
* @param rawClass the raw class to create a parameterized type instance for
|
||||||
* @param typeArguments the types used for parameterization
|
* @param typeArguments the types used for parameterization
|
||||||
* @return {@link ParameterizedType}
|
* @return {@link ParameterizedType}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static final ParameterizedType parameterize(final Class<?> raw, final Type... typeArguments) {
|
public static final ParameterizedType parameterize(final Class<?> rawClass, final Type... typeArguments) {
|
||||||
return parameterizeWithOwner(null, raw, typeArguments);
|
return parameterizeWithOwner(null, rawClass, typeArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a parameterized type instance.
|
* Create a parameterized type instance.
|
||||||
*
|
*
|
||||||
* @param raw the raw class to create a parameterized type instance for
|
* @param rawClass the raw class to create a parameterized type instance for
|
||||||
* @param typeArgMappings the mapping used for parameterization
|
* @param typeArgMappings the mapping used for parameterization
|
||||||
* @return {@link ParameterizedType}
|
* @return {@link ParameterizedType}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static final ParameterizedType parameterize(final Class<?> raw,
|
public static final ParameterizedType parameterize(final Class<?> rawClass,
|
||||||
final Map<TypeVariable<?>, Type> typeArgMappings) {
|
final Map<TypeVariable<?>, Type> typeArgMappings) {
|
||||||
Validate.notNull(raw, "raw class is null");
|
Validate.notNull(rawClass, "raw class is null");
|
||||||
Validate.notNull(typeArgMappings, "typeArgMappings is null");
|
Validate.notNull(typeArgMappings, "typeArgMappings is null");
|
||||||
return parameterizeWithOwner(null, raw, extractTypeArgumentsFrom(typeArgMappings, raw.getTypeParameters()));
|
return parameterizeWithOwner(null, rawClass,
|
||||||
|
extractTypeArgumentsFrom(typeArgMappings, rawClass.getTypeParameters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a parameterized type instance.
|
* Create a parameterized type instance.
|
||||||
*
|
*
|
||||||
* @param owner the owning type
|
* @param owner the owning type
|
||||||
* @param raw the raw class to create a parameterized type instance for
|
* @param rawClass the raw class to create a parameterized type instance for
|
||||||
* @param typeArguments the types used for parameterization
|
* @param typeArguments the types used for parameterization
|
||||||
*
|
*
|
||||||
* @return {@link ParameterizedType}
|
* @return {@link ParameterizedType}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static final ParameterizedType parameterizeWithOwner(final Type owner, final Class<?> raw,
|
public static final ParameterizedType parameterizeWithOwner(final Type owner, final Class<?> rawClass,
|
||||||
final Type... typeArguments) {
|
final Type... typeArguments) {
|
||||||
Validate.notNull(raw, "raw class is null");
|
Validate.notNull(rawClass, "raw class is null");
|
||||||
final Type useOwner;
|
final Type useOwner;
|
||||||
if (raw.getEnclosingClass() == null) {
|
if (rawClass.getEnclosingClass() == null) {
|
||||||
Validate.isTrue(owner == null, "no owner allowed for top-level %s", raw);
|
Validate.isTrue(owner == null, "no owner allowed for top-level %s", rawClass);
|
||||||
useOwner = null;
|
useOwner = null;
|
||||||
} else if (owner == null) {
|
} else if (owner == null) {
|
||||||
useOwner = raw.getEnclosingClass();
|
useOwner = rawClass.getEnclosingClass();
|
||||||
} else {
|
} else {
|
||||||
Validate.isTrue(isAssignable(owner, raw.getEnclosingClass()),
|
Validate.isTrue(isAssignable(owner, rawClass.getEnclosingClass()),
|
||||||
"%s is invalid owner type for parameterized %s", owner, raw);
|
"%s is invalid owner type for parameterized %s", owner, rawClass);
|
||||||
useOwner = owner;
|
useOwner = owner;
|
||||||
}
|
}
|
||||||
Validate.noNullElements(typeArguments, "null type argument at index %s");
|
Validate.noNullElements(typeArguments, "null type argument at index %s");
|
||||||
Validate.isTrue(raw.getTypeParameters().length == typeArguments.length,
|
Validate.isTrue(rawClass.getTypeParameters().length == typeArguments.length,
|
||||||
"invalid number of type parameters specified: expected %d, got %d", raw.getTypeParameters().length,
|
"invalid number of type parameters specified: expected %d, got %d", rawClass.getTypeParameters().length,
|
||||||
typeArguments.length);
|
typeArguments.length);
|
||||||
|
|
||||||
return new ParameterizedTypeImpl(raw, useOwner, typeArguments);
|
return new ParameterizedTypeImpl(rawClass, useOwner, typeArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a parameterized type instance.
|
* Create a parameterized type instance.
|
||||||
*
|
*
|
||||||
* @param owner the owning type
|
* @param owner the owning type
|
||||||
* @param raw the raw class to create a parameterized type instance for
|
* @param rawClass the raw class to create a parameterized type instance for
|
||||||
* @param typeArgMappings the mapping used for parameterization
|
* @param typeArgMappings the mapping used for parameterization
|
||||||
* @return {@link ParameterizedType}
|
* @return {@link ParameterizedType}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static final ParameterizedType parameterizeWithOwner(final Type owner, final Class<?> raw,
|
public static final ParameterizedType parameterizeWithOwner(final Type owner, final Class<?> rawClass,
|
||||||
final Map<TypeVariable<?>, Type> typeArgMappings) {
|
final Map<TypeVariable<?>, Type> typeArgMappings) {
|
||||||
Validate.notNull(raw, "raw class is null");
|
Validate.notNull(rawClass, "raw class is null");
|
||||||
Validate.notNull(typeArgMappings, "typeArgMappings is null");
|
Validate.notNull(typeArgMappings, "typeArgMappings is null");
|
||||||
return parameterizeWithOwner(owner, raw, extractTypeArgumentsFrom(typeArgMappings, raw.getTypeParameters()));
|
return parameterizeWithOwner(owner, rawClass,
|
||||||
|
extractTypeArgumentsFrom(typeArgMappings, rawClass.getTypeParameters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1563,39 +1566,40 @@ public static GenericArrayType genericArrayType(final Type componentType) {
|
|||||||
/**
|
/**
|
||||||
* Check equality of types.
|
* Check equality of types.
|
||||||
*
|
*
|
||||||
* @param t1 the first type
|
* @param type1 the first type
|
||||||
* @param t2 the second type
|
* @param type2 the second type
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public static boolean equals(final Type t1, final Type t2) {
|
public static boolean equals(final Type type1, final Type type2) {
|
||||||
if (Objects.equals(t1, t2)) {
|
if (Objects.equals(type1, type2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (t1 instanceof ParameterizedType) {
|
if (type1 instanceof ParameterizedType) {
|
||||||
return equals((ParameterizedType) t1, t2);
|
return equals((ParameterizedType) type1, type2);
|
||||||
}
|
}
|
||||||
if (t1 instanceof GenericArrayType) {
|
if (type1 instanceof GenericArrayType) {
|
||||||
return equals((GenericArrayType) t1, t2);
|
return equals((GenericArrayType) type1, type2);
|
||||||
}
|
}
|
||||||
if (t1 instanceof WildcardType) {
|
if (type1 instanceof WildcardType) {
|
||||||
return equals((WildcardType) t1, t2);
|
return equals((WildcardType) type1, type2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Learn whether {@code t} equals {@code p}.
|
* Learn whether {@code t} equals {@code p}.
|
||||||
* @param p LHS
|
* @param parameterizedType LHS
|
||||||
* @param t RHS
|
* @param type RHS
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static boolean equals(final ParameterizedType p, final Type t) {
|
private static boolean equals(final ParameterizedType parameterizedType, final Type type) {
|
||||||
if (t instanceof ParameterizedType) {
|
if (type instanceof ParameterizedType) {
|
||||||
final ParameterizedType other = (ParameterizedType) t;
|
final ParameterizedType other = (ParameterizedType) type;
|
||||||
if (equals(p.getRawType(), other.getRawType()) && equals(p.getOwnerType(), other.getOwnerType())) {
|
if (equals(parameterizedType.getRawType(), other.getRawType())
|
||||||
return equals(p.getActualTypeArguments(), other.getActualTypeArguments());
|
&& equals(parameterizedType.getOwnerType(), other.getOwnerType())) {
|
||||||
|
return equals(parameterizedType.getActualTypeArguments(), other.getActualTypeArguments());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -1603,43 +1607,43 @@ private static boolean equals(final ParameterizedType p, final Type t) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Learn whether {@code t} equals {@code a}.
|
* Learn whether {@code t} equals {@code a}.
|
||||||
* @param a LHS
|
* @param genericArrayType LHS
|
||||||
* @param t RHS
|
* @param type RHS
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static boolean equals(final GenericArrayType a, final Type t) {
|
private static boolean equals(final GenericArrayType genericArrayType, final Type type) {
|
||||||
return t instanceof GenericArrayType
|
return type instanceof GenericArrayType
|
||||||
&& equals(a.getGenericComponentType(), ((GenericArrayType) t).getGenericComponentType());
|
&& equals(genericArrayType.getGenericComponentType(), ((GenericArrayType) type).getGenericComponentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Learn whether {@code t} equals {@code w}.
|
* Learn whether {@code t} equals {@code w}.
|
||||||
* @param w LHS
|
* @param wildcardType LHS
|
||||||
* @param t RHS
|
* @param type RHS
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static boolean equals(final WildcardType w, final Type t) {
|
private static boolean equals(final WildcardType wildcardType, final Type type) {
|
||||||
if (t instanceof WildcardType) {
|
if (type instanceof WildcardType) {
|
||||||
final WildcardType other = (WildcardType) t;
|
final WildcardType other = (WildcardType) type;
|
||||||
return equals(getImplicitLowerBounds(w), getImplicitLowerBounds(other))
|
return equals(getImplicitLowerBounds(wildcardType), getImplicitLowerBounds(other))
|
||||||
&& equals(getImplicitUpperBounds(w), getImplicitUpperBounds(other));
|
&& equals(getImplicitUpperBounds(wildcardType), getImplicitUpperBounds(other));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Learn whether {@code t1} equals {@code t2}.
|
* Learn whether {@code t1} equals {@code t2}.
|
||||||
* @param t1 LHS
|
* @param type1 LHS
|
||||||
* @param t2 RHS
|
* @param type2 RHS
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static boolean equals(final Type[] t1, final Type[] t2) {
|
private static boolean equals(final Type[] type1, final Type[] type2) {
|
||||||
if (t1.length == t2.length) {
|
if (type1.length == type2.length) {
|
||||||
for (int i = 0; i < t1.length; i++) {
|
for (int i = 0; i < type1.length; i++) {
|
||||||
if (!equals(t1[i], t2[i])) {
|
if (!equals(type1[i], type2[i])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1730,25 +1734,25 @@ public static <T> Typed<T> wrap(final Class<T> type) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a {@link Class} as a {@link String}.
|
* Format a {@link Class} as a {@link String}.
|
||||||
* @param c {@code Class} to format
|
* @param cls {@code Class} to format
|
||||||
* @return String
|
* @return String
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static String classToString(final Class<?> c) {
|
private static String classToString(final Class<?> cls) {
|
||||||
if (c.isArray()) {
|
if (cls.isArray()) {
|
||||||
return toString(c.getComponentType()) + "[]";
|
return toString(cls.getComponentType()) + "[]";
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder buf = new StringBuilder();
|
final StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
if (c.getEnclosingClass() != null) {
|
if (cls.getEnclosingClass() != null) {
|
||||||
buf.append(classToString(c.getEnclosingClass())).append('.').append(c.getSimpleName());
|
buf.append(classToString(cls.getEnclosingClass())).append('.').append(cls.getSimpleName());
|
||||||
} else {
|
} else {
|
||||||
buf.append(c.getName());
|
buf.append(cls.getName());
|
||||||
}
|
}
|
||||||
if (c.getTypeParameters().length > 0) {
|
if (cls.getTypeParameters().length > 0) {
|
||||||
buf.append('<');
|
buf.append('<');
|
||||||
appendAllTo(buf, ", ", c.getTypeParameters());
|
appendAllTo(buf, ", ", cls.getTypeParameters());
|
||||||
buf.append('>');
|
buf.append('>');
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
@ -1756,72 +1760,75 @@ private static String classToString(final Class<?> c) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a {@link TypeVariable} as a {@link String}.
|
* Format a {@link TypeVariable} as a {@link String}.
|
||||||
* @param v {@code TypeVariable} to format
|
* @param typeVariable {@code TypeVariable} to format
|
||||||
* @return String
|
* @return String
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static String typeVariableToString(final TypeVariable<?> v) {
|
private static String typeVariableToString(final TypeVariable<?> typeVariable) {
|
||||||
final StringBuilder buf = new StringBuilder(v.getName());
|
final StringBuilder buf = new StringBuilder(typeVariable.getName());
|
||||||
final Type[] bounds = v.getBounds();
|
final Type[] bounds = typeVariable.getBounds();
|
||||||
if (bounds.length > 0 && !(bounds.length == 1 && Object.class.equals(bounds[0]))) {
|
if (bounds.length > 0 && !(bounds.length == 1 && Object.class.equals(bounds[0]))) {
|
||||||
buf.append(" extends ");
|
buf.append(" extends ");
|
||||||
appendAllTo(buf, " & ", v.getBounds());
|
appendAllTo(buf, " & ", typeVariable.getBounds());
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a {@link ParameterizedType} as a {@link String}.
|
* Format a {@link ParameterizedType} as a {@link String}.
|
||||||
* @param p {@code ParameterizedType} to format
|
* @param parameterizedType {@code ParameterizedType} to format
|
||||||
* @return String
|
* @return String
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static String parameterizedTypeToString(final ParameterizedType p) {
|
private static String parameterizedTypeToString(final ParameterizedType parameterizedType) {
|
||||||
final StringBuilder buf = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
final Type useOwner = p.getOwnerType();
|
final Type useOwner = parameterizedType.getOwnerType();
|
||||||
final Class<?> raw = (Class<?>) p.getRawType();
|
final Class<?> raw = (Class<?>) parameterizedType.getRawType();
|
||||||
|
|
||||||
if (useOwner == null) {
|
if (useOwner == null) {
|
||||||
buf.append(raw.getName());
|
builder.append(raw.getName());
|
||||||
} else {
|
} else {
|
||||||
if (useOwner instanceof Class<?>) {
|
if (useOwner instanceof Class<?>) {
|
||||||
buf.append(((Class<?>) useOwner).getName());
|
builder.append(((Class<?>) useOwner).getName());
|
||||||
} else {
|
} else {
|
||||||
buf.append(useOwner.toString());
|
builder.append(useOwner.toString());
|
||||||
}
|
}
|
||||||
buf.append('.').append(raw.getSimpleName());
|
builder.append('.').append(raw.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|
||||||
final int[] recursiveTypeIndexes = findRecursiveTypes(p);
|
final int[] recursiveTypeIndexes = findRecursiveTypes(parameterizedType);
|
||||||
|
|
||||||
if (recursiveTypeIndexes.length > 0) {
|
if (recursiveTypeIndexes.length > 0) {
|
||||||
appendRecursiveTypes(buf, recursiveTypeIndexes, p.getActualTypeArguments());
|
appendRecursiveTypes(builder, recursiveTypeIndexes, parameterizedType.getActualTypeArguments());
|
||||||
} else {
|
} else {
|
||||||
appendAllTo(buf.append('<'), ", ", p.getActualTypeArguments()).append('>');
|
appendAllTo(builder.append('<'), ", ", parameterizedType.getActualTypeArguments()).append('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendRecursiveTypes(final StringBuilder buf, final int[] recursiveTypeIndexes, final Type[] argumentTypes) {
|
private static void appendRecursiveTypes(final StringBuilder builder, final int[] recursiveTypeIndexes,
|
||||||
|
final Type[] argumentTypes) {
|
||||||
for (int i = 0; i < recursiveTypeIndexes.length; i++) {
|
for (int i = 0; i < recursiveTypeIndexes.length; i++) {
|
||||||
appendAllTo(buf.append('<'), ", ", argumentTypes[i].toString()).append('>');
|
appendAllTo(builder.append('<'), ", ", argumentTypes[i].toString()).append('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
final Type[] argumentsFiltered = ArrayUtils.removeAll(argumentTypes, recursiveTypeIndexes);
|
final Type[] argumentsFiltered = ArrayUtils.removeAll(argumentTypes, recursiveTypeIndexes);
|
||||||
|
|
||||||
if (argumentsFiltered.length > 0) {
|
if (argumentsFiltered.length > 0) {
|
||||||
appendAllTo(buf.append('<'), ", ", argumentsFiltered).append('>');
|
appendAllTo(builder.append('<'), ", ", argumentsFiltered).append('>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[] findRecursiveTypes(final ParameterizedType p) {
|
private static int[] findRecursiveTypes(final ParameterizedType parameterizedType) {
|
||||||
final Type[] filteredArgumentTypes = Arrays.copyOf(p.getActualTypeArguments(), p.getActualTypeArguments().length);
|
final Type[] filteredArgumentTypes = Arrays.copyOf(parameterizedType.getActualTypeArguments(),
|
||||||
|
parameterizedType.getActualTypeArguments().length);
|
||||||
int[] indexesToRemove = {};
|
int[] indexesToRemove = {};
|
||||||
for (int i = 0; i < filteredArgumentTypes.length; i++) {
|
for (int i = 0; i < filteredArgumentTypes.length; i++) {
|
||||||
if (filteredArgumentTypes[i] instanceof TypeVariable<?>) {
|
if (filteredArgumentTypes[i] instanceof TypeVariable<?>) {
|
||||||
if (containsVariableTypeSameParametrizedTypeBound(((TypeVariable<?>) filteredArgumentTypes[i]), p)) {
|
if (containsVariableTypeSameParametrizedTypeBound(((TypeVariable<?>) filteredArgumentTypes[i]),
|
||||||
|
parameterizedType)) {
|
||||||
indexesToRemove = ArrayUtils.add(indexesToRemove, i);
|
indexesToRemove = ArrayUtils.add(indexesToRemove, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1829,20 +1836,21 @@ private static int[] findRecursiveTypes(final ParameterizedType p) {
|
|||||||
return indexesToRemove;
|
return indexesToRemove;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean containsVariableTypeSameParametrizedTypeBound(final TypeVariable<?> typeVariable, final ParameterizedType p) {
|
private static boolean containsVariableTypeSameParametrizedTypeBound(final TypeVariable<?> typeVariable,
|
||||||
return ArrayUtils.contains(typeVariable.getBounds(), p);
|
final ParameterizedType parameterizedType) {
|
||||||
|
return ArrayUtils.contains(typeVariable.getBounds(), parameterizedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a {@link WildcardType} as a {@link String}.
|
* Format a {@link WildcardType} as a {@link String}.
|
||||||
* @param w {@code WildcardType} to format
|
* @param wildcardType {@code WildcardType} to format
|
||||||
* @return String
|
* @return String
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static String wildcardTypeToString(final WildcardType w) {
|
private static String wildcardTypeToString(final WildcardType wildcardType) {
|
||||||
final StringBuilder buf = new StringBuilder().append('?');
|
final StringBuilder buf = new StringBuilder().append('?');
|
||||||
final Type[] lowerBounds = w.getLowerBounds();
|
final Type[] lowerBounds = wildcardType.getLowerBounds();
|
||||||
final Type[] upperBounds = w.getUpperBounds();
|
final Type[] upperBounds = wildcardType.getUpperBounds();
|
||||||
if (lowerBounds.length > 1 || lowerBounds.length == 1 && lowerBounds[0] != null) {
|
if (lowerBounds.length > 1 || lowerBounds.length == 1 && lowerBounds[0] != null) {
|
||||||
appendAllTo(buf.append(" super "), " & ", lowerBounds);
|
appendAllTo(buf.append(" super "), " & ", lowerBounds);
|
||||||
} else if (upperBounds.length > 1 || upperBounds.length == 1 && !Object.class.equals(upperBounds[0])) {
|
} else if (upperBounds.length > 1 || upperBounds.length == 1 && !Object.class.equals(upperBounds[0])) {
|
||||||
@ -1853,31 +1861,32 @@ private static String wildcardTypeToString(final WildcardType w) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a {@link GenericArrayType} as a {@link String}.
|
* Format a {@link GenericArrayType} as a {@link String}.
|
||||||
* @param g {@code GenericArrayType} to format
|
* @param genericArrayType {@code GenericArrayType} to format
|
||||||
* @return String
|
* @return String
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static String genericArrayTypeToString(final GenericArrayType g) {
|
private static String genericArrayTypeToString(final GenericArrayType genericArrayType) {
|
||||||
return String.format("%s[]", toString(g.getGenericComponentType()));
|
return String.format("%s[]", toString(genericArrayType.getGenericComponentType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append {@code types} to {@code buf} with separator {@code sep}.
|
* Append {@code types} to {@code builder} with separator {@code sep}.
|
||||||
* @param buf destination
|
* @param builder destination
|
||||||
* @param sep separator
|
* @param sep separator
|
||||||
* @param types to append
|
* @param types to append
|
||||||
* @return {@code buf}
|
* @return {@code builder}
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
private static <T> StringBuilder appendAllTo(final StringBuilder buf, final String sep, final T... types) {
|
private static <T> StringBuilder appendAllTo(final StringBuilder builder, final String sep,
|
||||||
|
@SuppressWarnings("unchecked") final T... types) {
|
||||||
Validate.notEmpty(Validate.noNullElements(types));
|
Validate.notEmpty(Validate.noNullElements(types));
|
||||||
if (types.length > 0) {
|
if (types.length > 0) {
|
||||||
buf.append(toString(types[0]));
|
builder.append(toString(types[0]));
|
||||||
for (int i = 1; i < types.length; i++) {
|
for (int i = 1; i < types.length; i++) {
|
||||||
buf.append(sep).append(toString(types[i]));
|
builder.append(sep).append(toString(types[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> String toString(final T object) {
|
private static <T> String toString(final T object) {
|
||||||
|
@ -35,7 +35,9 @@
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class NumericEntityUnescaper extends CharSequenceTranslator {
|
public class NumericEntityUnescaper extends CharSequenceTranslator {
|
||||||
|
|
||||||
public enum OPTION { semiColonRequired, semiColonOptional, errorIfNoSemiColon }
|
public enum OPTION {
|
||||||
|
semiColonRequired, semiColonOptional, errorIfNoSemiColon
|
||||||
|
}
|
||||||
|
|
||||||
// TODO?: Create an OptionsSet class to hide some of the conditional logic below
|
// TODO?: Create an OptionsSet class to hide some of the conditional logic below
|
||||||
private final EnumSet<OPTION> options;
|
private final EnumSet<OPTION> options;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user