001package com.nimbusds.infinispan.persistence.sql.config;
002
003
004import java.util.HashMap;
005import java.util.Map;
006
007
008/**
009 * SQL store XML configuration attributes.
010 */
011public enum Attribute {
012        
013        
014        /**
015         * Unknown XML attribute.
016         */
017        UNKNOWN(null), // must be first
018        
019        
020        /**
021         * The XML attribute for the SQL record transformer.
022         */
023        RECORD_TRANSFORMER("record-transformer"),
024        
025        
026        /**
027         * The XML attribute for the SQL query executor.
028         */
029        QUERY_EXECUTOR("query-executor"),
030        
031        
032        /**
033         * The XML attribute for the SQL dialect.
034         */
035        SQL_DIALECT("sql-dialect");
036        
037        
038        
039        /**
040         * The attribute name.
041         */
042        private final String name;
043        
044        
045        /**
046         * Creates a new attribute with the specified name.
047         *
048         * @param name The attribute name.
049         */
050        Attribute(final String name) {
051                this.name = name;
052        }
053        
054        
055        /**
056         * Gets the local name of this attribute.
057         *
058         * @return The local name.
059         */
060        public String getLocalName() {
061                return name;
062        }
063        
064        
065        /**
066         * The enumerated attributes as map.
067         */
068        private static final Map<String, Attribute> attributes;
069        
070        static {
071                final Map<String, Attribute> map = new HashMap<>();
072                for (Attribute attribute : values()) {
073                        final String name = attribute.getLocalName();
074                        if (name != null) {
075                                map.put(name, attribute);
076                        }
077                }
078                attributes = map;
079        }
080        
081        
082        /**
083         * Returns the matching attribute for the specified local name.
084         *
085         * @param localName The local name.
086         *
087         * @return The attribute.
088         */
089        public static Attribute forName(final String localName) {
090                final Attribute attribute = attributes.get(localName);
091                return attribute == null ? UNKNOWN : attribute;
092        }
093}