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 * The optional XML attribute for the create table if missing setting. 040 */ 041 CREATE_TABLE_IF_MISSING("create-table-if-missing"); 042 043 044 045 /** 046 * The attribute name. 047 */ 048 private final String name; 049 050 051 /** 052 * Creates a new attribute with the specified name. 053 * 054 * @param name The attribute name. 055 */ 056 Attribute(final String name) { 057 this.name = name; 058 } 059 060 061 /** 062 * Gets the local name of this attribute. 063 * 064 * @return The local name. 065 */ 066 public String getLocalName() { 067 return name; 068 } 069 070 071 /** 072 * The enumerated attributes as map. 073 */ 074 private static final Map<String, Attribute> attributes; 075 076 static { 077 final Map<String, Attribute> map = new HashMap<>(); 078 for (Attribute attribute : values()) { 079 final String name = attribute.getLocalName(); 080 if (name != null) { 081 map.put(name, attribute); 082 } 083 } 084 attributes = map; 085 } 086 087 088 /** 089 * Returns the matching attribute for the specified local name. 090 * 091 * @param localName The local name. 092 * 093 * @return The attribute. 094 */ 095 public static Attribute forName(final String localName) { 096 final Attribute attribute = attributes.get(localName); 097 return attribute == null ? UNKNOWN : attribute; 098 } 099}