// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.command.system;

import javax.annotation.Nullable;
import com.hypixel.hytale.common.util.StringCompareUtil;
import javax.annotation.Nonnull;

public class MatchResult implements Comparable<MatchResult>
{
    public static final MatchResult NONE;
    public static final MatchResult EXACT;
    public static final int NAME = 0;
    public static final int ALIAS = 1;
    public static final int USAGE_ARG = 3;
    public static final int DESCRIPTION = 4;
    public static final int USAGE_DESCRIPTION = 5;
    private final int term;
    private final int depth;
    private final int type;
    private final int match;
    
    @Nonnull
    public static MatchResult of(final int termDepth, final int depth, final int type, @Nonnull final String text, @Nonnull final String search) {
        return new MatchResult(termDepth, depth, type, StringCompareUtil.getLevenshteinDistance(text, search));
    }
    
    public MatchResult(final int term, final int depth, final int type, final int match) {
        this.term = term;
        this.depth = depth;
        this.type = type;
        this.match = match;
    }
    
    public int getDepth() {
        return this.depth;
    }
    
    public int getType() {
        return this.type;
    }
    
    public int getMatch() {
        return this.match;
    }
    
    @Nonnull
    public MatchResult min(@Nonnull final MatchResult other) {
        if (this.term < other.term) {
            return this;
        }
        if (this.term > other.term) {
            return other;
        }
        if (this.type < other.type) {
            return this;
        }
        if (this.type > other.type) {
            return other;
        }
        if (this.depth < other.depth) {
            return this;
        }
        if (this.depth > other.depth) {
            return other;
        }
        if (this.match < other.match) {
            return this;
        }
        if (this.match > other.match) {
            return other;
        }
        return this;
    }
    
    @Override
    public int compareTo(@Nonnull final MatchResult o) {
        if (o.term != this.term) {
            return this.term - o.term;
        }
        if (o.type != this.type) {
            return this.type - o.type;
        }
        if (o.depth != this.depth) {
            return this.depth - o.depth;
        }
        return this.match - o.match;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final MatchResult that = (MatchResult)o;
        return this.depth == that.depth && this.match == that.match;
    }
    
    @Override
    public int hashCode() {
        int result = this.depth;
        result = 31 * result + this.match;
        return result;
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "MatchResult{depth=" + this.depth + ", match=" + this.match;
    }
    
    static {
        NONE = new MatchResult(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
        EXACT = new MatchResult(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    }
}
