java.lang.Object
net.joseplay.allianceutils.api.playerProfile.entity.FeatureManager

public class FeatureManager extends Object
Manages dynamic key-value features for a profile.

This class provides a flexible storage system where values are associated with NameSpace keys. Only a restricted set of primitive wrapper types and common objects are allowed.

Supported types include:

  • String
  • Numeric wrappers (Integer, Long, etc.)
  • Boolean
  • Character
  • UUID

Thread-safety is partially guaranteed via ConcurrentHashMap, but compound operations are not atomic.

The manager tracks a "dirty" state indicating if data has changed and needs persistence.

  • Constructor Details

    • FeatureManager

      public FeatureManager()
  • Method Details

    • isValidObj

      public boolean isValidObj(Object o)
      Checks if the given object is a valid feature value.
      Parameters:
      o - object to validate
      Returns:
      true if valid
    • ensureMaps

      public void ensureMaps()
      Ensures the internal map is initialized. Useful after deserialization.
    • hasFeature

      public boolean hasFeature(NameSpace nameSpace)
      Checks if a feature exists.
      Parameters:
      nameSpace - feature key
      Returns:
      true if present
    • removeFeature

      public void removeFeature(NameSpace nameSpace)
      Removes a feature.
      Parameters:
      nameSpace - feature key
    • feature

      public Object feature(NameSpace nameSpace)
      Returns the raw feature value.
      Parameters:
      nameSpace - feature key
      Returns:
      stored value or null
    • setFeature

      public void setFeature(NameSpace nameSpace, Object o)
      Sets a feature value.
      Parameters:
      nameSpace - feature key
      o - value to store
      Throws:
      RuntimeException - if type is invalid
    • getBoolean

      public boolean getBoolean(NameSpace nameSpace, boolean defaultValue)
      Retrieves a boolean value.
    • getBoolean

      public boolean getBoolean(NameSpace nameSpace)
    • getString

      public String getString(NameSpace nameSpace, String defaultValue)
      Retrieves a string value.
    • getString

      public String getString(NameSpace nameSpace)
    • getInt

      public int getInt(NameSpace nameSpace, int defaultValue)
      Retrieves an integer value.
    • getInt

      public int getInt(NameSpace nameSpace)
    • getLong

      public long getLong(NameSpace nameSpace, long defaultValue)
      Retrieves a long value.
    • getLong

      public long getLong(NameSpace nameSpace)
    • getUUID

      public UUID getUUID(NameSpace nameSpace)
      Retrieves a UUID value.
      Returns:
      UUID or null (no safety check)
    • setDirty

      public void setDirty(boolean dirty)
      Marks the data as modified.
    • isDirty

      public boolean isDirty()
      Returns whether the data was modified.
    • getFeatures

      public Map<String,Object> getFeatures()
      Returns the raw feature map.

      WARNING: this exposes internal mutable state.