Class Cvl

java.lang.Object
com.mayam.wf.config.shared.Cvl
All Implemented Interfaces:
Copyable, Serializable

public class Cvl extends Object implements Serializable, Copyable
A Control Value List (CVL) to be associated with a Field, providing a list of valid choices. The data type of each individual value is String regardless of associated attribute. These strings MUST be convertible to the actual value class of the attribute. Fields of attributes having a value class corresponding to an enum has two possible types: Cvl.Type.ENUM with which all enum values are choices (default translations where applicable), and the Cvl.Type.ENUM_SUBSET which corresponds to a subset where translation overrides are possible. For attributes with other value classes, there are six options: Cvl.Type.STATIC will store a static control value list with translations within the configuration. A type of Cvl.Type.SITE, Cvl.Type.USER_SITE, or Cvl.Type.MAM together with a remote identifier will define a dynamic list with values received from site code or MAM dictionary respectively. The Cvl.Type.MAM_USER will fetch a mam user list (possibly filtered by a group name) and the Cvl.Type.MAM_GROUP will fetch a mam group list, possibly filtered by a regExp filter The USER_SITE will cause the site code implementation to be provided with the name of the user accessing the CVL. For this reason, a USER_SITE CVL cannot be cached server wide as is done with the SITE and MAM.
Author:
Markus MÃ¥rtensson
See Also:
  • Constructor Details

    • Cvl

      public Cvl()
  • Method Details

    • equals

      public boolean equals(Object peer)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTextForValue

      public TranslatedString getTextForValue(String value)
      Returns the value for a given key of this CVL. Returns null if doesn't exist
      Parameters:
      value -
      Returns:
      TranslatedString for given key
    • replaceWith

      public void replaceWith(ValueList list)
      Replaces the current CVL contents with the contents of the provided ValueList (which does not have i18n support). Used to inject values when type is Cvl.Type.SITE or Cvl.Type.MAM.
    • fromValueList

      public void fromValueList(ValueList list, boolean keepOriginal)
      Converts the provided ValueList (which does not have i18n support) into Cvl entries and adds them to the Cvl, optionally keeping the original entries in place. Allows for the combination of static entries followed by dynamic ones (eg. prefixCvl+mamCvl in preset).
    • asValueList

      public ValueList asValueList()
      Returns a ValueList representation of this Cvl, dropping i18n support.
    • asFilteredValueList

      public ValueList asFilteredValueList(Predicate<String> filter)
      Returns a filtered ValueList representation of this Cvl, dropping i18n support.
       asFilteredValueList(v->v.contains("poms"))
       
    • replaceWith

      public void replaceWith(Class<?> valueClass, EnumTranslations trans)
      Replaces the CVL with translated enumerations. In the case of Type.ENUM and Type.ENUM_SUBSET of size 0, the CVL gets entries matching those of the valueClass; whereas a subset of one or more values is retained but translated.
      Parameters:
      trans - if non-null, the this translation table will be used.
      enumClass - the enum from which the value list is taken.
    • getType

      public Cvl.Type getType()
    • setType

      public void setType(Cvl.Type type)
    • getDefaultValue

      public String getDefaultValue()
    • setDefaultValue

      public void setDefaultValue(String defaultValue)
    • getEntries

      public List<Cvl.Entry> getEntries()
    • getRemoteId

      public String getRemoteId()
    • setRemoteId

      public void setRemoteId(String remoteId)
    • lookup

      public TranslatedString lookup(String value)
      Looks up a translation for a given value, returning null if none was found.
    • copy

      public Cvl copy()
      Description copied from interface: Copyable
      Performs a deep copy of the object.
      Specified by:
      copy in interface Copyable
      Returns:
      new copy.