2626 * Simple detection for well known cloud platforms. Detection can be forced using the
2727 * {@code "spring.main.cloud-platform"} configuration property.
2828 *
29- * <p>
30- * For more advanced cloud platform integration, consider using a platform-specific
31- * library such as <a href="https://github.com/pivotal-cf/java-cfenv">Java CFEnv</a> or
32- * <a href="https://spring.io/projects/spring-cloud-kubernetes">Spring Cloud
33- * Kubernetes</a>.
34- *
3529 * @author Phillip Webb
3630 * @author Brian Clozel
3731 * @since 1.3.0
@@ -44,7 +38,7 @@ public enum CloudPlatform {
4438 NONE {
4539
4640 @ Override
47- public boolean isAutoDetected (Environment environment ) {
41+ public boolean isDetected (Environment environment ) {
4842 return false ;
4943 }
5044
@@ -56,7 +50,7 @@ public boolean isAutoDetected(Environment environment) {
5650 CLOUD_FOUNDRY {
5751
5852 @ Override
59- public boolean isAutoDetected (Environment environment ) {
53+ public boolean isDetected (Environment environment ) {
6054 return environment .containsProperty ("VCAP_APPLICATION" ) || environment .containsProperty ("VCAP_SERVICES" );
6155 }
6256
@@ -68,7 +62,7 @@ public boolean isAutoDetected(Environment environment) {
6862 HEROKU {
6963
7064 @ Override
71- public boolean isAutoDetected (Environment environment ) {
65+ public boolean isDetected (Environment environment ) {
7266 return environment .containsProperty ("DYNO" );
7367 }
7468
@@ -80,7 +74,7 @@ public boolean isAutoDetected(Environment environment) {
8074 SAP {
8175
8276 @ Override
83- public boolean isAutoDetected (Environment environment ) {
77+ public boolean isDetected (Environment environment ) {
8478 return environment .containsProperty ("HC_LANDSCAPE" );
8579 }
8680
@@ -100,7 +94,7 @@ public boolean isAutoDetected(Environment environment) {
10094 private static final String SERVICE_PORT_SUFFIX = "_SERVICE_PORT" ;
10195
10296 @ Override
103- public boolean isAutoDetected (Environment environment ) {
97+ public boolean isDetected (Environment environment ) {
10498 if (environment instanceof ConfigurableEnvironment ) {
10599 return isAutoDetected ((ConfigurableEnvironment ) environment );
106100 }
@@ -143,30 +137,29 @@ private boolean isAutoDetected(EnumerablePropertySource<?> environmentPropertySo
143137 * @return if the platform is active.
144138 */
145139 public boolean isActive (Environment environment ) {
146- return isEnforced (environment ) || isAutoDetected (environment );
140+ return isEnforced (environment ) || isDetected (environment );
147141 }
148142
149143 /**
150- * Detemines if the platform is enforced by looking at the
144+ * Determines if the platform is enforced by looking at the
151145 * {@code "spring.main.cloud-platform"} configuration property.
152146 * @param environment the environment
153147 * @return if the platform is enforced
148+ * @since 2.3.0
154149 */
155150 public boolean isEnforced (Environment environment ) {
156151 String platform = environment .getProperty ("spring.main.cloud-platform" );
157- if (platform != null ) {
158- return this .name ().equalsIgnoreCase (platform );
159- }
160- return false ;
152+ return (platform != null ) ? this .name ().equalsIgnoreCase (platform ) : false ;
161153 }
162154
163155 /**
164- * Determines if the platform is auto- detected by looking for platform-specific
165- * environment variables.
156+ * Determines if the platform is detected by looking for platform-specific environment
157+ * variables.
166158 * @param environment the environment
167159 * @return if the platform is auto-detected.
160+ * @since 2.3.0
168161 */
169- public abstract boolean isAutoDetected (Environment environment );
162+ public abstract boolean isDetected (Environment environment );
170163
171164 /**
172165 * Returns if the platform is behind a load balancer and uses
0 commit comments