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

import java.io.Serializable;

public final class ExtendedClassInfo implements Serializable {
   private static final long serialVersionUID = 1L;
   private final boolean exact;
   private final String location;
   private final String version;

   public ExtendedClassInfo(boolean exact, String location, String version) {
      this.exact = exact;
      this.location = location;
      this.version = version;
   }

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

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

            return true;
         }
      }
   }

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

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

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

   public int hashCode() {
      int prime = true;
      int result = 1;
      int result = 31 * result + (this.exact ? 1231 : 1237);
      result = 31 * result + (this.location == null ? 0 : this.location.hashCode());
      result = 31 * result + (this.version == null ? 0 : this.version.hashCode());
      return result;
   }

   public String toString() {
      StringBuilder sb = new StringBuilder();
      if (!this.exact) {
         sb.append('~');
      }

      sb.append('[');
      sb.append(this.location);
      sb.append(':');
      sb.append(this.version);
      sb.append(']');
      return sb.toString();
   }
}
