Class CodeItemImpl

java.lang.Object
com.iizix.prop.CodeItemImpl
All Implemented Interfaces:
ICodeItem, Cloneable

public class CodeItemImpl extends Object implements ICodeItem, Cloneable
The code item implementation.
Author:
Christopher Mindus
  • Constructor Details

    • CodeItemImpl

      public CodeItemImpl(String value)
      Constructor for an item without code.
      Parameters:
      value - The item value, never null.
      Throws:
      NullPointerException - If item value is null.
    • CodeItemImpl

      public CodeItemImpl(String code, String value)
      Constructor for an item with code and value.
      Parameters:
      code - The code, perhaps null for none.
      value - The item value, never null.
      Throws:
      NullPointerException - If item value is null.
    • CodeItemImpl

      public CodeItemImpl(KString value)
      Constructor for an item without code.
      Parameters:
      value - The item value, never null.
      Throws:
      NullPointerException - If item value is null.
    • CodeItemImpl

      public CodeItemImpl(String code, KString value)
      Constructor for an item with code and value.
      Parameters:
      code - The code, perhaps null for none.
      value - The item value, never null.
      Throws:
      NullPointerException - If item value is null.
  • Method Details

    • clone

      public CodeItemImpl clone()
      Clones the instance.
      Overrides:
      clone in class Object
      Returns:
      The cloned instance if it contains a KString, otherwise "this" instance.
    • equals

      public boolean equals(Object o)
      Checks for equality.
      Overrides:
      equals in class Object
      Parameters:
      o - Another object.
      Returns:
      true if equal, false otherwise.
    • hasCode

      public boolean hasCode()
      Checks if this item has a code.
      Specified by:
      hasCode in interface ICodeItem
      Returns:
      true if code is present, false otherwise.
    • isKString

      public boolean isKString()
      Returns whether the item is a KString or not.
      Specified by:
      isKString in interface ICodeItem
      Returns:
      true if item is a KString, false for String.
    • getCode

      public String getCode()
      Gets the code string.
      Specified by:
      getCode in interface ICodeItem
      Returns:
      The optional code string, perhaps null for none.
    • getString

      public String getString()
      Gets the item text as a String.
      Specified by:
      getString in interface ICodeItem
      Returns:
      The item String, potentially converted from KString.
    • getKString

      public KString getKString()
      Gets the item text as a KString.
      Specified by:
      getKString in interface ICodeItem
      Returns:
      The item KString, potentially converted from String.
    • getValue

      public Object getValue()
      Gets the value.
      Specified by:
      getValue in interface ICodeItem
      Returns:
      Either a String or a KString.