Module org.autogui

Class GuiReprValueBooleanCheckBox

java.lang.Object
org.autogui.base.mapping.GuiReprValue
org.autogui.base.mapping.GuiReprValueBooleanCheckBox
All Implemented Interfaces:
GuiRepresentation

public class GuiReprValueBooleanCheckBox extends GuiReprValue
an abstract checkbox component for a Boolean or primitive boolean property
      @GuiIncluded public boolean prop;
  
  • Constructor Details

    • GuiReprValueBooleanCheckBox

      public GuiReprValueBooleanCheckBox()
  • Method Details

    • matchValueType

      public boolean matchValueType(Class<?> cls)
      Overrides:
      matchValueType in class GuiReprValue
    • toUpdateValue

      public Boolean toUpdateValue(GuiMappingContext context, Object newValue)
      Description copied from class: GuiReprValue
      called from a GUI element in order to update its value. subclass can change to returned type and convert the value to the type. a typical use case is just down-casting and converting null to an empty object.
      Overrides:
      toUpdateValue in class GuiReprValue
      Parameters:
      context - the context of the repr.
      newValue - the current value
      Returns:
      the updated value
    • toJson

      public Object toJson(GuiMappingContext context, Object source)
      Description copied from interface: GuiRepresentation
      convert the source into JSON format
      Specified by:
      toJson in interface GuiRepresentation
      Overrides:
      toJson in class GuiReprValue
      Parameters:
      context - a context holds the representation
      source - the converted object
      Returns:
      Boolean
    • fromJson

      public Object fromJson(GuiMappingContext context, Object target, Object json)
      Description copied from interface: GuiRepresentation
      create a new value object from the JSON with treating the target as an old value, or update the target with the JSON contents. the behavior can be varied by each representation, confirmed by GuiRepresentation.isJsonSetter().
      Specified by:
      fromJson in interface GuiRepresentation
      Overrides:
      fromJson in class GuiReprValue
      Parameters:
      context - a context holds the representation
      target - the target object or null
      json - JSON objects representing the target String, Number, Boolean, List, Map or null
      Returns:
      created object from the json, target if provided, or null.
    • toHumanReadableString

      public String toHumanReadableString(GuiMappingContext context, Object source)
      Description copied from interface: GuiRepresentation
      method for constructing "toString" copy operations: the returned string will be separated by tabs and new-lines
      Parameters:
      context - the context of the repr.
      source - converted to string
      Returns:
      a string representation of the source
    • fromHumanReadableString

      public Object fromHumanReadableString(GuiMappingContext context, String str)
      Parameters:
      context - the context (ignored)
      str - the source string
      Returns:
      a Boolean value
    • isJsonSetter

      public boolean isJsonSetter()
      Returns:
      true means GuiRepresentation.fromJson(GuiMappingContext, Object, Object) takes a target object and set json properties to the target. otherwise, the method will return a new value, thus the target can be null
    • getBooleanValue

      public Boolean getBooleanValue(String data)
      Parameters:
      data - a source string
      Returns:
      false for "false" or "0". true for "true" or digits. case insensitive. null for null