Package fr.olympus.prometheus.register
Record Class EntityRegistryEntry
java.lang.Object
java.lang.Record
fr.olympus.prometheus.register.EntityRegistryEntry
- Record Components:
id- The unique identifier for the entity.supplier- A supplier that provides instances of the entity when requested.groups- An array of group identifiers that this entity belongs to, used for categorization and retrieval purposes.
public record EntityRegistryEntry(String id, Supplier<? extends IEntity> supplier, String[] groups)
extends Record
Represents an entry in the entity registry, containing the entity's unique identifier and a supplier for creating instances of the entity.
-
Constructor Summary
ConstructorsConstructorDescriptionEntityRegistryEntry(String id, Supplier<? extends IEntity> supplier, String[] groups) Constructs a new EntityRegistryEntry with the specified unique identifier and supplier. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance of the entity using the supplier.final booleanIndicates whether some other object is "equal to" this one.String[]groups()Returns the value of thegroupsrecord component.booleanChecks if the entity belongs to a specific group.booleanChecks if the entity belongs to all specified groups.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.supplier()Returns the value of thesupplierrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
EntityRegistryEntry
Constructs a new EntityRegistryEntry with the specified unique identifier and supplier.- Parameters:
id- The unique identifier for the entity.supplier- A supplier that provides instances of the entity when requested.- Throws:
IllegalArgumentException- if id is null or if supplier is null.
-
-
Method Details
-
createInstance
Creates a new instance of the entity using the supplier.- Returns:
- A new instance of the entity provided by the supplier.
- Throws:
RuntimeException- if the supplier fails to create an instance.IllegalStateException- if the created instance is null or not an instance of IEntity
-
hasGroup
Checks if the entity belongs to a specific group.- Parameters:
group- The group identifier to check against the entity's groups.- Returns:
- true if the entity belongs to the specified group, false otherwise.
-
hasGroups
Checks if the entity belongs to all specified groups.- Parameters:
groups- An array of group identifiers to check against the entity's groups.- Returns:
- true if the entity belongs to all specified groups, false otherwise.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
supplier
Returns the value of thesupplierrecord component.- Returns:
- the value of the
supplierrecord component
-
groups
Returns the value of thegroupsrecord component.- Returns:
- the value of the
groupsrecord component
-