Class EnumVocab<P extends Enum<P>>

java.lang.Object
com.adobe.epubcheck.vocab.EnumVocab<P>
All Implemented Interfaces:
Vocab

public final class EnumVocab<P extends Enum<P>> extends Object implements Vocab
A Vocab implementation that is backed by an Enum.

Property names will be computed from Enum constant names by applying the following transformation:

  • The name is converted to lower case
  • The underscore character ('_') is replaced by the hyphen character ('-').
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final com.google.common.base.Converter<P,String>
     
    private final Map<String,Property>
     
    private final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnumVocab(Class<P> clazz, com.google.common.base.CaseFormat format, String base)
    Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base.
    EnumVocab(Class<P> clazz, com.google.common.base.CaseFormat format, String base, String prefix)
    Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base and prefix prefix
    EnumVocab(Class<P> clazz, String base)
    Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base.
    EnumVocab(Class<P> clazz, String base, String prefix)
    Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base and prefix prefix
  • Method Summary

    Modifier and Type
    Method
    Description
    get(P property)
    Returns the Property for the given enum item contained in this vocabulary.
    getName(P property)
    Returns the property name for the given enum item contained in this vocabulary.
    getNames(Collection<P> properties)
    Returns the property names of the given enum items contained in this vocabulary.
    Returns the base URI of this vocabulary.
    com.google.common.base.Optional<Property>
    lookup(String name)
    Returns whether a property in allowed in this vocabulary.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • index

      private final Map<String,Property> index
    • uri

      private final String uri
    • converter

      private final com.google.common.base.Converter<P extends Enum<P>, String> converter
  • Constructor Details

    • EnumVocab

      public EnumVocab(Class<P> clazz, String base)
      Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base. 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(Class<P> clazz, com.google.common.base.CaseFormat format, String base)
      Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base. 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 vocabulary
      base - the common stem URI of properties in this vocabulary.
    • EnumVocab

      public EnumVocab(Class<P> clazz, String base, String prefix)
      Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base and prefix prefix
      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(Class<P> clazz, com.google.common.base.CaseFormat format, String base, String prefix)
      Creates a new vocabulary backed by the given Enum class and with properties having the common URI stem base and prefix prefix
      Parameters:
      clazz - the enumeration backing this vocabulary.
      format - the case format used by properties in this vocabulary
      base - the common stem URI of properties in this vocabulary.
      prefix - the common prefix of properties in this vocabulary.
  • Method Details

    • lookup

      public com.google.common.base.Optional<Property> lookup(String name)
      Description copied from interface: Vocab
      Returns whether a property in allowed in this vocabulary.
      Specified by:
      lookup in interface Vocab
      Parameters:
      name - the property name (unprefixed).
      Returns:
      an Property reference which contains a Property if the lookup was successful or nothing if the property was not found in this vocabulary.
    • getURI

      public String getURI()
      Description copied from interface: Vocab
      Returns the base URI of this vocabulary.
      Specified by:
      getURI in interface Vocab
      Returns:
      the base URI of this vocabulary.
    • get

      public Property get(P property)
      Returns the Property for the given enum item contained in this vocabulary.
      Parameters:
      property - the property to look up, must not be null
      Returns:
      the result of looking up property in this vocabulary.
    • getName

      public 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 be null
      Returns:
      the name of property.
    • getNames

      public Collection<String> getNames(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 be null
      Returns:
      the collection of the names of properties in properties.