package ervu_business_metrics.config;

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

/**
 * @author Adel Kalimullin
 */
public class KafkaEnabledCondition implements Condition {
  private static final String ERVU_KAFKA_ENABLED = "ervu.kafka.enabled";

  @Override
  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Environment env = context.getEnvironment();
    return Boolean.parseBoolean(env.getProperty(ERVU_KAFKA_ENABLED, "true"));
  }
}
