Class AttrOptions

java.lang.Object
com.iohao.net.common.kit.attr.AttrOptions
All Implemented Interfaces:
Serializable

public class AttrOptions extends Object implements Serializable
Thread-safe attribute storage container. Holds key-value pairs keyed by AttrOption instances.
Author:
渔民小镇
See Also:
date:
2022-01-31
  • Constructor Details

    • AttrOptions

      public AttrOptions(AttrOptions attrOptions)
      Create a new container by copying all entries from the given source.
      Parameters:
      attrOptions - the source container whose entries are copied into this instance
    • AttrOptions

      public AttrOptions()
      Create an empty attribute storage container.
  • Method Details

    • option

      public <T> T option(AttrOption<T> option)
      Gets the option value.

      Returns the default value if the option does not exist.

      Parameters:
      option - The attribute option
      Returns:
      The option value, or the default option value if the option does not exist.
    • option

      public <T> AttrOptions option(AttrOption<T> option, T value)
      Sets a new option with a specific value.

      Use a null value to remove the previously set AttrOption.

      Parameters:
      option - The attribute option
      value - The option value, null to remove the previously set AttrOption.
      Returns:
      this