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

import java.io.Serializable;

public final class ExtendedStackTraceElement implements Serializable {
   private static final long serialVersionUID = -2171069569241280505L;
   private final ExtendedClassInfo extraClassInfo;
   private final StackTraceElement stackTraceElement;

   public ExtendedStackTraceElement(StackTraceElement stackTraceElement, ExtendedClassInfo extraClassInfo) {
      this.stackTraceElement = stackTraceElement;
      this.extraClassInfo = extraClassInfo;
   }

   public ExtendedStackTraceElement(String declaringClass, String methodName, String fileName, int lineNumber, boolean exact, String location, String version) {
      this(new StackTraceElement(declaringClass, methodName, fileName, lineNumber), new ExtendedClassInfo(exact, location, version));
   }

   public boolean equals(Object obj) {
      if (this == obj) {
         return true;
      } else if (obj == null) {
         return false;
      } else if (!(obj instanceof ExtendedStackTraceElement)) {
         return false;
      } else {
         ExtendedStackTraceElement other = (ExtendedStackTraceElement)obj;
         if (this.extraClassInfo == null) {
            if (other.extraClassInfo != null) {
               return false;
            }
         } else if (!this.extraClassInfo.equals(other.extraClassInfo)) {
            return false;
         }

         if (this.stackTraceElement == null) {
            if (other.stackTraceElement != null) {
               return false;
            }
         } else if (!this.stackTraceElement.equals(other.stackTraceElement)) {
            return false;
         }

         return true;
      }
   }

   public String getClassName() {
      return this.stackTraceElement.getClassName();
   }

   public boolean getExact() {
      return this.extraClassInfo.getExact();
   }

   public ExtendedClassInfo getExtraClassInfo() {
      return this.extraClassInfo;
   }

   public String getFileName() {
      return this.stackTraceElement.getFileName();
   }

   public int getLineNumber() {
      return this.stackTraceElement.getLineNumber();
   }

   public String getLocation() {
      return this.extraClassInfo.getLocation();
   }

   public String getMethodName() {
      return this.stackTraceElement.getMethodName();
   }

   public StackTraceElement getStackTraceElement() {
      return this.stackTraceElement;
   }

   public String getVersion() {
      return this.extraClassInfo.getVersion();
   }

   public int hashCode() {
      int prime = true;
      int result = 1;
      int result = 31 * result + (this.extraClassInfo == null ? 0 : this.extraClassInfo.hashCode());
      result = 31 * result + (this.stackTraceElement == null ? 0 : this.stackTraceElement.hashCode());
      return result;
   }

   public boolean isNativeMethod() {
      return this.stackTraceElement.isNativeMethod();
   }

   public String toString() {
      StringBuilder sb = new StringBuilder();
      sb.append(this.stackTraceElement);
      sb.append(" ");
      sb.append(this.extraClassInfo);
      return sb.toString();
   }
}
