package ru.micord.ervu.audit.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 AuditEnabledCondition implements Condition {
  private static final String AUDIT_ENABLED_PROPERTY_NAME = "audit.kafka.enabled";

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