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 - The RequirementMeta annotation 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 Details

    • RequirementInfo

      public RequirementInfo(Annotation annotation)
      Constructs a RequirementInfo from 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 a RequirementInfo record class.
      Parameters:
      annotation - the value for the annotation record component
      meta - the value for the meta record component
      values - the value for the values record component
  • Method Details

    • hasValue

      public boolean hasValue(@NotNull @NotNull String key)
      Checks whether the given key exists in the annotation's values.
      Parameters:
      key - The key to check.
      Returns:
      true if the key exists, false otherwise.
    • getValue

      public <T> @Unmodifiable T getValue(@NotNull @NotNull String key)
      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 null if not present.
    • merge

      public static RequirementInfo merge(RequirementInfo first, RequirementInfo second)
      Merges two RequirementInfo instances 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 first RequirementInfo.
      second - the second RequirementInfo.
      Returns:
      a merged RequirementInfo.
      Throws:
      IllegalStateException - if the two instances refer to different annotations.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • annotation

      public Class<? extends Annotation> annotation()
      Returns the value of the annotation record component.
      Returns:
      the value of the annotation record component
    • meta

      public RequirementMeta meta()
      Returns the value of the meta record component.
      Returns:
      the value of the meta record component
    • values

      public Map<String,Object> values()
      Returns the value of the values record component.
      Returns:
      the value of the values record component