Class FeatureManager
java.lang.Object
net.joseplay.allianceutils.api.playerProfile.entity.FeatureManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the internal map is initialized.Returns the raw feature value.booleangetBoolean(NameSpace nameSpace) booleangetBoolean(NameSpace nameSpace, boolean defaultValue) Retrieves a boolean value.Returns the raw feature map.intintRetrieves an integer value.longlongRetrieves a long value.Retrieves a string value.Retrieves a UUID value.booleanhasFeature(NameSpace nameSpace) Checks if a feature exists.booleanisDirty()Returns whether the data was modified.booleanisValidObj(Object o) Checks if the given object is a valid feature value.voidremoveFeature(NameSpace nameSpace) Removes a feature.voidsetDirty(boolean dirty) Marks the data as modified.voidsetFeature(NameSpace nameSpace, Object o) Sets a feature value.
-
Constructor Details
-
FeatureManager
public FeatureManager()
-
-
Method Details
-
isValidObj
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
Checks if a feature exists.- Parameters:
nameSpace- feature key- Returns:
- true if present
-
removeFeature
Removes a feature.- Parameters:
nameSpace- feature key
-
feature
Returns the raw feature value.- Parameters:
nameSpace- feature key- Returns:
- stored value or null
-
setFeature
Sets a feature value.- Parameters:
nameSpace- feature keyo- value to store- Throws:
RuntimeException- if type is invalid
-
getBoolean
Retrieves a boolean value. -
getBoolean
-
getString
Retrieves a string value. -
getString
-
getInt
Retrieves an integer value. -
getInt
-
getLong
Retrieves a long value. -
getLong
-
getUUID
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
Returns the raw feature map.WARNING: this exposes internal mutable state.
-