package org.apache.logging.log4j.core.pattern;

import java.util.Date;
import org.apache.logging.log4j.core.config.plugins.Plugin;

@Plugin(
   name = "IntegerPatternConverter",
   category = "FileConverter"
)
@ConverterKeys({"i", "index"})
public final class IntegerPatternConverter extends AbstractPatternConverter implements ArrayPatternConverter {
   private static final IntegerPatternConverter INSTANCE = new IntegerPatternConverter();

   private IntegerPatternConverter() {
      super("Integer", "integer");
   }

   public static IntegerPatternConverter newInstance(String[] options) {
      return INSTANCE;
   }

   public void format(StringBuilder toAppendTo, Object... objects) {
      Object[] arr$ = objects;
      int len$ = objects.length;

      for(int i$ = 0; i$ < len$; ++i$) {
         Object obj = arr$[i$];
         if (obj instanceof Integer) {
            this.format(obj, toAppendTo);
            break;
         }
      }

   }

   public void format(Object obj, StringBuilder toAppendTo) {
      if (obj instanceof Integer) {
         toAppendTo.append(obj.toString());
      } else if (obj instanceof Date) {
         toAppendTo.append(Long.toString(((Date)obj).getTime()));
      }

   }
}
