/*
 *  Copyright 2011 Eric F. Savage, code@efsavage.com
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.ajah.http;

import com.ajah.util.Identifiable;

/**
 * Enum for HTTP methods.
 * 
 * @author <a href="http://efsavage.com">Eric F. Savage</a>, <a
 *         href="mailto:code@efsavage.com">code@efsavage.com</a>.
 * 
 */
public enum HttpMethod implements Identifiable<String> {

	/**
	 * GET
	 */
	GET("2"),
	/**
	 * POST
	 */
	POST("5"),
	/**
	 * DELETE
	 */
	DELETE("1"),
	/**
	 * HEAD
	 */
	HEAD("3"),
	/**
	 * OPTIONS
	 */
	OPTIONS("4"),
	/**
	 * PUT
	 */
	PUT("6"),
	/**
	 * TRACE
	 */
	TRACE("7");

	/**
	 * Finds a matching method and returns the proper value, or null if
	 * unmatched.
	 * 
	 * @param method
	 *            The name of the method to attempt to match.
	 * @return The matching enum value, or null if unmatched.
	 */
	public static HttpMethod get(final String method) {
		for (final HttpMethod candidate : values()) {
			if (candidate.name().equals(method)) {
				return candidate;
			}
		}
		return null;
	}

	private String id;

	private HttpMethod(final String id) {
		this.id = id;
	}

	/**
	 * Returns the ID of this method. This ID is arbitrary and has no meaning
	 * outside of this enum class.
	 * 
	 * @see com.ajah.util.Identifiable#getId()
	 */
	@Override
	public String getId() {
		return this.id;
	}

	/**
	 * Throws UnsupportedOperationException, included only to satisfy
	 * {@link Identifiable} interface.
	 * 
	 * @see com.ajah.util.Identifiable#setId(java.lang.Comparable)
	 */
	@Override
	public void setId(final String id) {
		throw new UnsupportedOperationException();
	}

}

@@ -687,16 +687,55 @@
 ifiable;
+%0Aimport com.ajah.util.IdentifiableEnum;
 %0A%0A/**%0A *
@@ -946,16 +946,20 @@
 tifiable
+Enum
 %3CString%3E
@@ -988,16 +988,30 @@
 %09GET(%222%22
+, %22get%22, %22GET%22
 ),%0A%09/**%0A
@@ -1033,16 +1033,32 @@
 POST(%225%22
+, %22post%22, %22POST%22
 ),%0A%09/**%0A
@@ -1084,16 +1084,36 @@
 LETE(%221%22
+, %22delete%22, %22DELETE%22
 ),%0A%09/**%0A
@@ -1135,16 +1135,32 @@
 HEAD(%223%22
+, %22head%22, %22HEAD%22
 ),%0A%09/**%0A
@@ -1188,16 +1188,38 @@
 IONS(%224%22
+, %22options%22, %22OPTIONS%22
 ),%0A%09/**%0A
@@ -1239,16 +1239,30 @@
 %09PUT(%226%22
+, %22put%22, %22PUT%22
 ),%0A%09/**%0A
@@ -1286,16 +1286,34 @@
 RACE(%227%22
+, %22trace%22, %22TRACE%22
 );%0A%0A%09/**
@@ -1745,16 +1745,22 @@
 private 
+final 
 String i
@@ -1766,62 +1766,288 @@
 id;%0A
-%0A%09private HttpMethod(final String id) %7B%0A%09%09this.id = id
+%09private final String code;%0A%09public String getCode() %7B%0A%09%09return code;%0A%09%7D%0A%0A%09public String getName() %7B%0A%09%09return name;%0A%09%7D%0A%0A%09private final String name;%0A%0A%09private HttpMethod(final String id, final String code, final String name) %7B%0A%09%09this.id = id;%0A%09%09this.code = code;%0A%09%09this.name = name
 ;%0A%09%7D

Update to IdentifiableEnum