From 2e4e43b5bdd6c548fcb644540e09559fd3433969 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Thu, 31 Aug 2023 13:38:13 +0200 Subject: [PATCH] Polish org.springframework.core.env.PropertySource See gh-30195 --- .../core/env/PropertySource.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/env/PropertySource.java b/spring-core/src/main/java/org/springframework/core/env/PropertySource.java index f50968d2bba4..64ad2c0d9283 100644 --- a/spring-core/src/main/java/org/springframework/core/env/PropertySource.java +++ b/spring-core/src/main/java/org/springframework/core/env/PropertySource.java @@ -92,6 +92,8 @@ public PropertySource(String name) { /** * Return the name of this {@code PropertySource}. + *

See the {@linkplain PropertySource class-level Javadoc} for details + * on property source identity and names. */ public String getName() { return this.name; @@ -170,21 +172,22 @@ public String toString() { /** - * Return a {@code PropertySource} implementation intended for collection comparison purposes only. - *

Primarily for internal use, but given a collection of {@code PropertySource} objects, may be - * used as follows: + * Return a {@code PropertySource} implementation intended for collection + * comparison purposes only. + *

Primarily for internal use, but given a collection of {@code PropertySource} + * objects, may be used as follows: *

-	 * {@code List> sources = new ArrayList>();
+	 * List<PropertySource<?>> sources = new ArrayList<>();
 	 * sources.add(new MapPropertySource("sourceA", mapA));
 	 * sources.add(new MapPropertySource("sourceB", mapB));
 	 * assert sources.contains(PropertySource.named("sourceA"));
 	 * assert sources.contains(PropertySource.named("sourceB"));
-	 * assert !sources.contains(PropertySource.named("sourceC"));
-	 * }
- * The returned {@code PropertySource} will throw {@code UnsupportedOperationException} + * assert !sources.contains(PropertySource.named("sourceC")); + *

The returned {@code PropertySource} will throw {@code UnsupportedOperationException} * if any methods other than {@code equals(Object)}, {@code hashCode()}, and {@code toString()} * are called. - * @param name the name of the comparison {@code PropertySource} to be created and returned. + * @param name the name of the comparison {@code PropertySource} to be created + * and returned */ public static PropertySource named(String name) { return new ComparisonPropertySource(name); @@ -206,7 +209,7 @@ public static PropertySource named(String name) { public static class StubPropertySource extends PropertySource { public StubPropertySource(String name) { - super(name, new Object()); + super(name); } /**