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

package io.netty.handler.codec.http;

import io.netty.util.internal.ObjectUtil;
import io.netty.util.AsciiString;

public class HttpMethod implements Comparable<HttpMethod>
{
    private static final String GET_STRING = "GET";
    private static final String POST_STRING = "POST";
    public static final HttpMethod OPTIONS;
    public static final HttpMethod GET;
    public static final HttpMethod HEAD;
    public static final HttpMethod POST;
    public static final HttpMethod PUT;
    public static final HttpMethod PATCH;
    public static final HttpMethod DELETE;
    public static final HttpMethod TRACE;
    public static final HttpMethod CONNECT;
    private final AsciiString name;
    
    public static HttpMethod valueOf(final String name) {
        switch (name) {
            case "OPTIONS": {
                return HttpMethod.OPTIONS;
            }
            case "GET": {
                return HttpMethod.GET;
            }
            case "HEAD": {
                return HttpMethod.HEAD;
            }
            case "POST": {
                return HttpMethod.POST;
            }
            case "PUT": {
                return HttpMethod.PUT;
            }
            case "PATCH": {
                return HttpMethod.PATCH;
            }
            case "DELETE": {
                return HttpMethod.DELETE;
            }
            case "TRACE": {
                return HttpMethod.TRACE;
            }
            case "CONNECT": {
                return HttpMethod.CONNECT;
            }
            default: {
                return new HttpMethod(name);
            }
        }
    }
    
    public HttpMethod(String name) {
        name = ObjectUtil.checkNonEmptyAfterTrim(name, "name");
        final int index = HttpUtil.validateToken(name);
        if (index != -1) {
            throw new IllegalArgumentException("Illegal character in HTTP Method: 0x" + Integer.toHexString(name.charAt(index)));
        }
        this.name = AsciiString.cached(name);
    }
    
    public String name() {
        return this.name.toString();
    }
    
    public AsciiString asciiName() {
        return this.name;
    }
    
    @Override
    public int hashCode() {
        return this.name().hashCode();
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof HttpMethod)) {
            return false;
        }
        final HttpMethod that = (HttpMethod)o;
        return this.name().equals(that.name());
    }
    
    @Override
    public String toString() {
        return this.name.toString();
    }
    
    @Override
    public int compareTo(final HttpMethod o) {
        if (o == this) {
            return 0;
        }
        return this.name().compareTo(o.name());
    }
    
    static {
        OPTIONS = new HttpMethod("OPTIONS");
        GET = new HttpMethod("GET");
        HEAD = new HttpMethod("HEAD");
        POST = new HttpMethod("POST");
        PUT = new HttpMethod("PUT");
        PATCH = new HttpMethod("PATCH");
        DELETE = new HttpMethod("DELETE");
        TRACE = new HttpMethod("TRACE");
        CONNECT = new HttpMethod("CONNECT");
    }
}
