/*
 * Copyright 2020 Schibsted ASA.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.netflix.spinnaker.front50.config.annotations;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class AnyProviderExceptRedisCondition implements Condition {

  @Override
  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Environment env = context.getEnvironment();
    return serviceEnabled("sql", env)
        || serviceEnabled("s3", env)
        || serviceEnabled("oracle", env)
        || serviceEnabled("gcs", env)
        || serviceEnabled("azs", env)
        || serviceEnabled("swift", env);
  }

  private static boolean serviceEnabled(String s, Environment env) {
    return env.getProperty(
        (s.equals("sql") ? "" : "spinnaker.") + s + ".enabled", Boolean.class, false);
  }
}

@@ -681,35 +681,54 @@
 amework.
-context.annotation.
+boot.autoconfigure.condition.AnyNested
 Conditio
@@ -761,36 +761,36 @@
 ork.
-context.annotation.C
+boot.autoconfigure.c
 ondition
 Cont
@@ -789,124 +789,30 @@
 tion
+.
 Con
-text;%0Aimport org.springframework.core.env.Environment;%0Aimport org.springframework.core.type.AnnotatedTypeMetadata
+ditionalOnProperty
 ;%0A%0Ap
@@ -859,19 +859,25 @@
 ion 
-implement
+extend
 s 
+AnyNested
 Cond
@@ -891,575 +891,584 @@
 %0A%0A  
-@Override%0A  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) %7B%0A    Environment env = context.getEnvironment();%0A    return serviceEnabled(%22sql%22, env)%0A        %7C%7C serviceEnabled(%22s3%22, env)%0A        %7C%7C serviceEnabled(%22oracle%22, env)%0A        %7C%7C serviceEnabled(%22gcs%22, env)%0A        %7C%7C serviceEnabled(%22azs%22, env)%0A        %7C%7C serviceEnabled(%22swift%22, env);%0A  %7D%0A%0A  private static boolean serviceEnabled(String s, Environment env) %7B%0A    return env.getProperty(%0A        (s.equals(%22sql%22) ? %22%22 : %22spinnaker.%22) + s + %22.enabled%22, Boolean.class, false);%0A  
+public AnyProviderExceptRedisCondition() %7B%0A    super(ConfigurationPhase.PARSE_CONFIGURATION);%0A  %7D%0A%0A  @ConditionalOnProperty(%22sql.enabled%22)%0A  static class SqlEnabled %7B%7D%0A%0A  @ConditionalOnProperty(%22spinnaker.s3.enabled%22)%0A  static class S3Enabled %7B%7D%0A%0A  @ConditionalOnProperty(%22spinnaker.oracle.enabled%22)%0A  static class OracleEnabled %7B%7D%0A%0A  @ConditionalOnProperty(%22spinnaker.gcs.enabled%22)%0A  static class GcsEnabled %7B%7D%0A%0A  @ConditionalOnProperty(%22spinnaker.azs.enabled%22)%0A  static class AzureEnabled %7B%7D%0A%0A  @ConditionalOnProperty(%22spinnaker.swift.enabled%22)%0A  static class SwiftEnabled %7B
 %7D%0A%7D%0A

Use nested conditions in AnyProviderExceptRedisCondition (#858)