001package ca.cdr.api.model.enm;
002
003/*
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import java.util.Collections;
014import java.util.HashMap;
015import java.util.Map;
016
017/**
018 * Simple enum for environments.
019 */
020public enum EnvironmentEnum {
021        /**
022         * Sorting agnostic.
023         */
024
025        /**
026         * Test
027         */
028        TEST("test"),
029
030        /**
031         * Development
032         */
033        DEV("dev"),
034
035        /**
036         * Staging
037         */
038        STAGING("stage"),
039
040        /**
041         * Production
042         */
043        PROD("prod");
044
045        private static Map<String, EnvironmentEnum> ourValues;
046        private String myCode;
047
048        private EnvironmentEnum(String theCode) {
049                myCode = theCode;
050        }
051
052        public String getCode() {
053                return myCode;
054        }
055
056        public static EnvironmentEnum fromCode(String theCode) {
057                if (ourValues == null) {
058                        HashMap<String, EnvironmentEnum> values = new HashMap<String, EnvironmentEnum>();
059                        for (EnvironmentEnum next : values()) {
060                                values.put(next.getCode(), next);
061                        }
062                        ourValues = Collections.unmodifiableMap(values);
063                }
064                return ourValues.get(theCode);
065        }
066}