Package com.adobe.epubcheck.vocab
Class EnumVocab<P extends java.lang.Enum<P>>
- java.lang.Object
-
- com.adobe.epubcheck.vocab.EnumVocab<P>
-
- All Implemented Interfaces:
Vocab
public final class EnumVocab<P extends java.lang.Enum<P>> extends java.lang.Object implements Vocab
AVocabimplementation that is backed by anEnum.Property names will be computed from
Enumconstant names by applying the following transformation:- The name is converted to lower case
- The underscore character (
'_') is replaced by the hyphen character ('-').
-
-
Constructor Summary
Constructors Constructor Description EnumVocab(java.lang.Class<P> clazz, com.google.common.base.CaseFormat format, java.lang.String base)Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembase.EnumVocab(java.lang.Class<P> clazz, com.google.common.base.CaseFormat format, java.lang.String base, java.lang.String prefix)Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembaseand prefixprefixEnumVocab(java.lang.Class<P> clazz, java.lang.String base)Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembase.EnumVocab(java.lang.Class<P> clazz, java.lang.String base, java.lang.String prefix)Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembaseand prefixprefix
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Propertyget(P property)Returns thePropertyfor the given enum item contained in this vocabulary.java.lang.StringgetName(P property)Returns the property name for the given enum item contained in this vocabulary.java.util.Collection<java.lang.String>getNames(java.util.Collection<P> properties)Returns the property names of the given enum items contained in this vocabulary.java.lang.StringgetURI()Returns the base URI of this vocabulary.com.google.common.base.Optional<Property>lookup(java.lang.String name)Returns whether a property in allowed in this vocabulary.
-
-
-
Constructor Detail
-
EnumVocab
public EnumVocab(java.lang.Class<P> clazz, java.lang.String base)
Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembase. Properties of the created vocabulary will have an empty prefix (in other words, this creates a default vocabulary).- Parameters:
clazz- the enumeration backing this vocabulary.base- the common stem URI of properties in this vocabulary.
-
EnumVocab
public EnumVocab(java.lang.Class<P> clazz, com.google.common.base.CaseFormat format, java.lang.String base)
Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembase. Properties of the created vocabulary will have an empty prefix (in other words, this creates a default vocabulary).- Parameters:
clazz- the enumeration backing this vocabulary.format- the case format used by properties in this vocabularybase- the common stem URI of properties in this vocabulary.
-
EnumVocab
public EnumVocab(java.lang.Class<P> clazz, java.lang.String base, java.lang.String prefix)
Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembaseand prefixprefix- Parameters:
clazz- the enumeration backing this vocabulary.base- the common stem URI of properties in this vocabulary.prefix- the common prefix of properties in this vocabulary.
-
EnumVocab
public EnumVocab(java.lang.Class<P> clazz, com.google.common.base.CaseFormat format, java.lang.String base, java.lang.String prefix)
Creates a new vocabulary backed by the givenEnumclass and with properties having the common URI stembaseand prefixprefix- Parameters:
clazz- the enumeration backing this vocabulary.format- the case format used by properties in this vocabularybase- the common stem URI of properties in this vocabulary.prefix- the common prefix of properties in this vocabulary.
-
-
Method Detail
-
lookup
public com.google.common.base.Optional<Property> lookup(java.lang.String name)
Description copied from interface:VocabReturns whether a property in allowed in this vocabulary.
-
getURI
public java.lang.String getURI()
Description copied from interface:VocabReturns the base URI of this vocabulary.
-
get
public Property get(P property)
Returns thePropertyfor the given enum item contained in this vocabulary.- Parameters:
property- the property to look up, must not benull- Returns:
- the result of looking up
propertyin this vocabulary.
-
getName
public java.lang.String getName(P property)
Returns the property name for the given enum item contained in this vocabulary.- Parameters:
property- the property to get the name of, must not benull- Returns:
- the name of
property.
-
getNames
public java.util.Collection<java.lang.String> getNames(java.util.Collection<P> properties)
Returns the property names of the given enum items contained in this vocabulary.- Parameters:
properties- a collection of properties to get the name of, must not benull- Returns:
- the collection of the names of properties in
properties.
-
-