PageRenderTime 41ms CodeModel.GetById 19ms app.highlight 10ms RepoModel.GetById 0ms app.codeStats 0ms

/jboss-as-7.1.1.Final/transactions/src/main/java/org/jboss/as/txn/subsystem/Element.java

#
Java | 79 lines | 35 code | 11 blank | 33 comment | 4 complexity | ffcb40e8dc4e7e33ccc23d33f8ddb58f MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
 1/*
 2 * JBoss, Home of Professional Open Source.
 3 * Copyright 2010, Red Hat, Inc., and individual contributors
 4 * as indicated by the @author tags. See the copyright.txt file in the
 5 * distribution for a full listing of individual contributors.
 6 *
 7 * This is free software; you can redistribute it and/or modify it
 8 * under the terms of the GNU Lesser General Public License as
 9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22
23package org.jboss.as.txn.subsystem;
24
25import java.util.HashMap;
26import java.util.Map;
27
28/**
29 * Enumeration of elements used in the transactions subsystem.
30 *
31 * @author John E. Bailey
32 * @author Scott Stark (sstark@redhat.com) (C) 2011 Red Hat Inc.
33 */
34enum Element {
35    // must be first
36    UNKNOWN(null),
37
38    RECOVERY_ENVIRONMENT("recovery-environment"),
39    CORE_ENVIRONMENT("core-environment"),
40    COORDINATOR_ENVIRONMENT("coordinator-environment"),
41    OBJECT_STORE("object-store"),
42    PROCESS_ID("process-id"),
43    SOCKET("socket"),
44    UUID("uuid"),
45    JTS("jts"),
46    ;
47
48    private final String name;
49
50    Element(final String name) {
51        this.name = name;
52    }
53
54    /**
55     * Get the local name of this element.
56     *
57     * @return the local name
58     */
59    public String getLocalName() {
60        return name;
61    }
62
63    private static final Map<String, Element> MAP;
64
65    static {
66        final Map<String, Element> map = new HashMap<String, Element>();
67        for (Element element : values()) {
68            final String name = element.getLocalName();
69            if (name != null) map.put(name, element);
70        }
71        MAP = map;
72    }
73
74    public static Element forName(String localName) {
75        final Element element = MAP.get(localName);
76        return element == null ? UNKNOWN : element;
77    }
78
79}