package com.airlock.iam.application.parameters.domain.model;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Arrays;

public enum LogFormat {
   SIMPLE("simple"),
   STRUCTURED("structured");

   private final String identifier;

   public static LogFormat parseLogFormat(String format) {
      if (format == null) {
         throw new IllegalStateException("Webserver log format type not specified.");
      } else {
         return Arrays.stream(values())
            .filter(env -> env.getIdentifier().equals(format))
            .findFirst()
            .orElseThrow(() -> new IllegalStateException("Invalid format type provided: " + format));
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   LogFormat(final String identifier) {
      this.identifier = identifier;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getIdentifier() {
      return this.identifier;
   }
}
