Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
* supplied by the advisors.
*/
public static final TargetSource EMPTY_TARGET_SOURCE = EmptyTargetSource.INSTANCE;

/** Empty advisor array constant. */
public static final Advisor[] EMPTY_ADVISORS = new Advisor[0];

/** Package-protected to allow direct access for efficiency. */
@SuppressWarnings("serial")
Expand Down Expand Up @@ -288,7 +289,7 @@ private boolean isAdvisorIntroducedInterface(Class<?> ifc) {

@Override
public final Advisor[] getAdvisors() {
return this.advisors.toArray(new Advisor[0]);
return this.advisors.toArray(EMPTY_ADVISORS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
@SuppressWarnings("serial")
public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable {
private static final MethodInterceptor [] EMPTY_INTERCEPTOR_ARRAY = new MethodInterceptor[0];

private final List<AdvisorAdapter> adapters = new ArrayList<>(3);

Expand Down Expand Up @@ -89,7 +90,7 @@ public MethodInterceptor[] getInterceptors(Advisor advisor) throws UnknownAdvice
if (interceptors.isEmpty()) {
throw new UnknownAdviceTypeException(advisor.getAdvice());
}
return interceptors.toArray(new MethodInterceptor[0]);
return interceptors.toArray(EMPTY_INTERCEPTOR_ARRAY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
@SuppressWarnings("serial")
public class MutablePropertyValues implements PropertyValues, Serializable {

private static final PropertyValue[] EMPTY_PROPERTY_VALUES = new PropertyValue[0];

private final List<PropertyValue> propertyValueList;

private @Nullable Set<String> processedProperties;
Expand Down Expand Up @@ -264,7 +266,7 @@ public Stream<PropertyValue> stream() {

@Override
public PropertyValue[] getPropertyValues() {
return this.propertyValueList.toArray(new PropertyValue[0]);
return this.propertyValueList.toArray(EMPTY_PROPERTY_VALUES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
public class BeanComponentDefinition extends BeanDefinitionHolder implements ComponentDefinition {

private static final BeanDefinition[] EMPTY_BEAN_DEFINITIONS = new BeanDefinition[0];
private static final BeanReference[] EMPTY_BEAN_REFERENCES = new BeanReference[0];

private final BeanDefinition[] innerBeanDefinitions;

private final BeanReference[] beanReferences;
Expand Down Expand Up @@ -84,8 +87,8 @@ else if (value instanceof BeanReference beanRef) {
references.add(beanRef);
}
}
this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[0]);
this.beanReferences = references.toArray(new BeanReference[0]);
this.innerBeanDefinitions = innerBeans.toArray(EMPTY_BEAN_DEFINITIONS);
this.beanReferences = references.toArray(EMPTY_BEAN_REFERENCES);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
*/
final class MergedAnnotationsCollection implements MergedAnnotations {

private static final MergedAnnotation<?> [] EMPTY_ANNOTATIONS = new MergedAnnotation<?>[0];

private final MergedAnnotation<?>[] annotations;

private final AnnotationTypeMappings[] mappings;


private MergedAnnotationsCollection(Collection<MergedAnnotation<?>> annotations) {
Assert.notNull(annotations, "Annotations must not be null");
this.annotations = annotations.toArray(new MergedAnnotation<?>[0]);
this.annotations = annotations.toArray(EMPTY_ANNOTATIONS);
this.mappings = new AnnotationTypeMappings[this.annotations.length];
for (int i = 0; i < this.annotations.length; i++) {
MergedAnnotation<?> annotation = this.annotations[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
*/
public abstract class TemplateAwareExpressionParser implements ExpressionParser {

private static final Expression [] EMPTY_EXPRESSION_ARRAY = new Expression[0];

@Override
public Expression parseExpression(String expressionString) throws ParseException {
return parseExpression(expressionString, null);
Expand Down Expand Up @@ -136,7 +138,7 @@ private Expression[] parseExpressions(String expressionString, ParserContext con
}
}

return expressions.toArray(new Expression[0]);
return expressions.toArray(EMPTY_EXPRESSION_ARRAY);
}

/**
Expand Down