/*
 * Copyright (C) 2012-present the original author or authors.
 *
 * 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 org.pf4j;

import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * @author Decebal Suiu
 */
public enum RuntimeMode {

	DEVELOPMENT("development"), // development
    DEPLOYMENT("deployment"); // deployment

    private final String name;

	private static final Map<String, RuntimeMode> map = new HashMap<>();

	static {
		for (RuntimeMode mode : RuntimeMode.values()) {
			map.put(mode.name, mode);
		}
	}

	private RuntimeMode(final String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return name;
    }

    public static RuntimeMode byName(String name) {
    	if (map.containsKey(name)) {
    		return map.get(name);
    	}

    	throw new NoSuchElementException("Cannot found PF4J runtime mode with name '" + name +
    			"'. Must be 'development' or 'deployment'.");
    }

}

@@ -788,17 +788,20 @@
 Mode %7B%0A%0A
-%09
+    
 DEVELOPM
@@ -817,16 +817,23 @@
 lopment%22
+, %22dev%22
 ), // de
@@ -869,16 +869,24 @@
 loyment%22
+, %22prod%22
 ); // de
@@ -926,18 +926,57 @@
 g name;%0A
-%0A%09
+    private final String%5B%5D aliases;%0A%0A    
 private 
@@ -1037,17 +1037,20 @@
 p%3C%3E();%0A%0A
-%09
+    
 static %7B
@@ -1050,18 +1050,24 @@
 tatic %7B%0A
-%09%09
+        
 for (Run
@@ -1106,19 +1106,28 @@
 es()) %7B%0A
-%09%09%09
+            
 map.put(
@@ -1148,17 +1148,129 @@
 e);%0A
-%09%09%7D%0A%09%7D%0A%0A%09
+            for (String alias : mode.aliases) %7B%0A                map.put(alias, mode);%0A            %7D%0A        %7D%0A    %7D%0A%0A    
 priv
@@ -1294,32 +1294,57 @@
 inal String name
+, final String... aliases
 ) %7B%0A        this
@@ -1353,24 +1353,56 @@
 ame = name;%0A
+        this.aliases = aliases;%0A
     %7D%0A%0A    @
@@ -1525,17 +1525,20 @@
 ) %7B%0A    
-%09
+    
 if (map.
@@ -1562,18 +1562,24 @@
 ) %7B%0A    
-%09%09
+        
 return m
@@ -1600,17 +1600,23 @@
     
-%09
+    
 %7D%0A%0A    
-%09
+    
 thro
@@ -1701,57 +1701,73 @@
 me +
-%0A    %09%09%09%22'. Must be 'development' or 'deployment'
+ %22'.%22 +%0A            %22Must be one value from '%22 + map.keySet() + %22
 .%22);

Add aliases to the runtime modes