Use Set.of() for constant sets where appropriate

This commit is contained in:
Sam Brannen
2022-11-21 15:57:32 +01:00
parent 0c878d2d06
commit 917c41fd52
12 changed files with 112 additions and 152 deletions

View File

@@ -17,7 +17,6 @@
package org.springframework.context.annotation;
import java.io.IOException;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -66,14 +65,12 @@ public abstract class ConfigurationClassUtils {
private static final Log logger = LogFactory.getLog(ConfigurationClassUtils.class);
private static final Set<String> candidateIndicators = new HashSet<>(8);
private static final Set<String> candidateIndicators = Set.of(
Component.class.getName(),
ComponentScan.class.getName(),
Import.class.getName(),
ImportResource.class.getName());
static {
candidateIndicators.add(Component.class.getName());
candidateIndicators.add(ComponentScan.class.getName());
candidateIndicators.add(Import.class.getName());
candidateIndicators.add(ImportResource.class.getName());
}
/**
* Initialize a configuration class proxy for the specified class.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.validation.beanvalidation;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -66,13 +65,8 @@ import org.springframework.validation.SmartValidator;
*/
public class SpringValidatorAdapter implements SmartValidator, jakarta.validation.Validator {
private static final Set<String> internalAnnotationAttributes = new HashSet<>(4);
private static final Set<String> internalAnnotationAttributes = Set.of("message", "groups", "payload");
static {
internalAnnotationAttributes.add("message");
internalAnnotationAttributes.add("groups");
internalAnnotationAttributes.add("payload");
}
@Nullable
private jakarta.validation.Validator targetValidator;