Record Class RequirementInfo
java.lang.Object
java.lang.Record
de.craftsblock.craftsnet.api.requirements.meta.RequirementInfo
- Record Components:
annotation- The class of the annotation.meta- TheRequirementMetaannotation metadata.values- A map of key-value pairs representing the annotation's values.
public record RequirementInfo(Class<? extends Annotation> annotation, RequirementMeta meta, Map<String,Object> values)
extends Record
Represents detailed information about a specific requirement annotation.
This class processes and stores metadata, methods, and values associated with the annotation.
- Since:
- 3.1.0-SNAPSHOT
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRequirementInfo(Annotation annotation) Constructs aRequirementInfofrom a given annotation.RequirementInfo(Class<? extends Annotation> annotation, RequirementMeta meta, Map<String, Object> values) Creates an instance of aRequirementInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionClass<? extends Annotation>Returns the value of theannotationrecord component.final booleanIndicates whether some other object is "equal to" this one.<T> @Unmodifiable TRetrieves the value associated with a given key from the annotation's values.final inthashCode()Returns a hash code value for this object.booleanChecks whether the given key exists in the annotation's values.static RequirementInfomerge(RequirementInfo first, RequirementInfo second) Merges twoRequirementInfoinstances into a single one.meta()Returns the value of themetarecord component.final StringtoString()Returns a string representation of this record class.values()Returns the value of thevaluesrecord component.
-
Constructor Details
-
RequirementInfo
Constructs aRequirementInfofrom a given annotation.- Parameters:
annotation- The annotation instance.
-
RequirementInfo
public RequirementInfo(Class<? extends Annotation> annotation, RequirementMeta meta, Map<String, Object> values) Creates an instance of aRequirementInforecord class.- Parameters:
annotation- the value for theannotationrecord componentmeta- the value for themetarecord componentvalues- the value for thevaluesrecord component
-
-
Method Details
-
hasValue
Checks whether the given key exists in the annotation's values.- Parameters:
key- The key to check.- Returns:
trueif the key exists,falseotherwise.
-
getValue
Retrieves the value associated with a given key from the annotation's values.- Parameters:
key- The key to retrieve the value for.- Returns:
- The value associated with the key, or
nullif not present.
-
merge
Merges twoRequirementInfoinstances into a single one.Conflicts between values are resolved as follows:
- If the values are arrays, they are concatenated.
- Otherwise, the value from the second instance overrides the first.
- Parameters:
first- the firstRequirementInfo.second- the secondRequirementInfo.- Returns:
- a merged
RequirementInfo. - Throws:
IllegalStateException- if the two instances refer to different annotations.
-
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). -
annotation
Returns the value of theannotationrecord component.- Returns:
- the value of the
annotationrecord component
-
meta
Returns the value of themetarecord component.- Returns:
- the value of the
metarecord component
-
values
Returns the value of thevaluesrecord component.- Returns:
- the value of the
valuesrecord component
-