From 53319381d049ccb32410a1046a6a3c58aa68ca6b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 12 Jul 2023 19:21:44 +0200 Subject: [PATCH] Polishing (cherry picked from commit c873a597c764492b0de917cb2f41adf67b6cfc67) --- .../ApplicationListenerMethodAdapter.java | 2 +- .../springframework/core/env/Environment.java | 38 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java index 8ad615848f1..68aeb85aef7 100644 --- a/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java +++ b/spring-context/src/main/java/org/springframework/context/event/ApplicationListenerMethodAdapter.java @@ -367,7 +367,7 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe * Return the target bean instance to use. */ protected Object getTargetBean() { - Assert.notNull(this.applicationContext, "ApplicationContext must no be null"); + Assert.notNull(this.applicationContext, "ApplicationContext must not be null"); return this.applicationContext.getBean(this.beanName); } diff --git a/spring-core/src/main/java/org/springframework/core/env/Environment.java b/spring-core/src/main/java/org/springframework/core/env/Environment.java index 38cc8bc2871..02dcf34f6d9 100644 --- a/spring-core/src/main/java/org/springframework/core/env/Environment.java +++ b/spring-core/src/main/java/org/springframework/core/env/Environment.java @@ -96,6 +96,25 @@ public interface Environment extends PropertyResolver { */ String[] getDefaultProfiles(); + /** + * Determine whether one of the given profile expressions matches the + * {@linkplain #getActiveProfiles() active profiles} — or in the case + * of no explicit active profiles, whether one of the given profile expressions + * matches the {@linkplain #getDefaultProfiles() default profiles}. + *

Profile expressions allow for complex, boolean profile logic to be + * expressed — for example {@code "p1 & p2"}, {@code "(p1 & p2) | p3"}, + * etc. See {@link Profiles#of(String...)} for details on the supported + * expression syntax. + *

This method is a convenient shortcut for + * {@code env.acceptsProfiles(Profiles.of(profileExpressions))}. + * @since 5.3.28 + * @see Profiles#of(String...) + * @see #acceptsProfiles(Profiles) + */ + default boolean matchesProfiles(String... profileExpressions) { + return acceptsProfiles(Profiles.of(profileExpressions)); + } + /** * Determine whether one or more of the given profiles is active — or * in the case of no explicit {@linkplain #getActiveProfiles() active profiles}, @@ -118,25 +137,6 @@ public interface Environment extends PropertyResolver { @Deprecated boolean acceptsProfiles(String... profiles); - /** - * Determine whether one of the given profile expressions matches the - * {@linkplain #getActiveProfiles() active profiles} — or in the case - * of no explicit active profiles, whether one of the given profile expressions - * matches the {@linkplain #getDefaultProfiles() default profiles}. - *

Profile expressions allow for complex, boolean profile logic to be - * expressed — for example {@code "p1 & p2"}, {@code "(p1 & p2) | p3"}, - * etc. See {@link Profiles#of(String...)} for details on the supported - * expression syntax. - *

This method is a convenient shortcut for - * {@code env.acceptsProfiles(Profiles.of(profileExpressions))}. - * @since 5.3.28 - * @see Profiles#of(String...) - * @see #acceptsProfiles(Profiles) - */ - default boolean matchesProfiles(String... profileExpressions) { - return acceptsProfiles(Profiles.of(profileExpressions)); - } - /** * Determine whether the given {@link Profiles} predicate matches the * {@linkplain #getActiveProfiles() active profiles} — or in the case