Skip to content

[pull] master from spring-projects:master #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 30, 2019
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@

package org.springframework.context.annotation;

import java.util.Objects;

import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.Nullable;

@@ -108,13 +106,17 @@ public boolean equals(@Nullable Object other) {
return false;
}
Entry entry = (Entry) other;
return (Objects.equals(this.metadata, entry.metadata) &&
Objects.equals(this.importClassName, entry.importClassName));
return (this.metadata.equals(entry.metadata) && this.importClassName.equals(entry.importClassName));
}

@Override
public int hashCode() {
return Objects.hash(this.metadata, this.importClassName);
return (this.metadata.hashCode() * 31 + this.importClassName.hashCode());
}

@Override
public String toString() {
return this.importClassName;
}
}
}
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.BiFunction;

@@ -179,30 +178,25 @@ private Method resolveAliasTarget(Method attribute, AliasFor aliasFor, boolean c
}
if (isAliasPair(target) && checkAliasPair) {
AliasFor targetAliasFor = target.getAnnotation(AliasFor.class);
if (targetAliasFor == null) {
throw new AnnotationConfigurationException(String.format(
"%s must be declared as an @AliasFor '%s'.",
StringUtils.capitalize(AttributeMethods.describe(target)),
attribute.getName()));
}
Method mirror = resolveAliasTarget(target, targetAliasFor, false);
if (!mirror.equals(attribute)) {
throw new AnnotationConfigurationException(String.format(
"%s must be declared as an @AliasFor '%s', not '%s'.",
StringUtils.capitalize(AttributeMethods.describe(target)),
attribute.getName(), mirror.getName()));
if (targetAliasFor != null) {
Method mirror = resolveAliasTarget(target, targetAliasFor, false);
if (!mirror.equals(attribute)) {
throw new AnnotationConfigurationException(String.format(
"%s must be declared as an @AliasFor '%s', not '%s'.",
StringUtils.capitalize(AttributeMethods.describe(target)),
attribute.getName(), mirror.getName()));
}
}
}
return target;
}

private boolean isAliasPair(Method target) {
return target.getDeclaringClass().equals(this.annotationType);
return (this.annotationType == target.getDeclaringClass());
}

private boolean isCompatibleReturnType(Class<?> attributeType, Class<?> targetType) {
return Objects.equals(attributeType, targetType) ||
Objects.equals(attributeType, targetType.getComponentType());
return (attributeType == targetType || attributeType == targetType.getComponentType());
}

private void processAliases() {
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.util.ReflectionUtils;

/**
* Provides a quick way to access the attribute methods of an {@link Annotation}
@@ -73,15 +74,11 @@ private AttributeMethods(@Nullable Class<? extends Annotation> annotationType, M
if (method.getDefaultValue() != null) {
foundDefaultValueMethod = true;
}
if (type.isAnnotation() ||
(type.isArray() && type.getComponentType().isAnnotation())) {
if (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation())) {
foundNestedAnnotation = true;
}
method.setAccessible(true);
this.canThrowTypeNotPresentException[i] =
type == Class.class ||
type == Class[].class ||
type.isEnum();
ReflectionUtils.makeAccessible(method);
this.canThrowTypeNotPresentException[i] = (type == Class.class || type == Class[].class || type.isEnum());
}
this.hasDefaultValueMethod = foundDefaultValueMethod;
this.hasNestedAnnotation = foundNestedAnnotation;
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
import java.lang.annotation.Repeatable;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Objects;

import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -83,7 +82,7 @@ public boolean equals(@Nullable Object other) {
if (other == null || getClass() != other.getClass()) {
return false;
}
return Objects.equals(this.parent, ((RepeatableContainers) other).parent);
return ObjectUtils.nullSafeEquals(this.parent, ((RepeatableContainers) other).parent);
}

@Override
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Objects;

import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
@@ -90,7 +89,7 @@ public Object invoke(Object proxy, Method method, Object[] args) {
}

private boolean isAnnotationTypeMethod(Method method) {
return (Objects.equals(method.getName(), "annotationType") && method.getParameterCount() == 0);
return (method.getName().equals("annotationType") && method.getParameterCount() == 0);
}

/**
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@

package org.springframework.util.unit;

import java.util.Objects;

/**
* A standard set of {@link DataSize} units.
*
@@ -92,7 +90,7 @@ DataSize size() {
*/
public static DataUnit fromSuffix(String suffix) {
for (DataUnit candidate : values()) {
if (Objects.equals(candidate.suffix, suffix)) {
if (candidate.suffix.equals(suffix)) {
return candidate;
}
}
Original file line number Diff line number Diff line change
@@ -1200,7 +1200,7 @@ static class MetaCycleAnnotatedClass {
@AliasFor("basePackages")
String[] value() default {};

@AliasFor("value")
// Intentionally no alias declaration for "value"
String[] basePackages() default {};

Filter[] excludeFilters() default {};
@@ -1485,15 +1485,15 @@ class ForAnnotationsClass {
}

@Retention(RetentionPolicy.RUNTIME)
static @interface ValueAttribute {
@interface ValueAttribute {

String[] value();

}

@Retention(RetentionPolicy.RUNTIME)
@ValueAttribute("FromValueAttributeMeta")
static @interface ValueAttributeMeta {
@interface ValueAttributeMeta {

@AliasFor("alias")
String[] value() default {};
@@ -1505,7 +1505,7 @@ class ForAnnotationsClass {

@Retention(RetentionPolicy.RUNTIME)
@ValueAttributeMeta("FromValueAttributeMetaMeta")
static @interface ValueAttributeMetaMeta {
@interface ValueAttributeMetaMeta {
}

@ValueAttributeMetaMeta
Loading