Record Class Replacement
java.lang.Object
java.lang.Record
me.a8kj.config.template.replacement.Replacement
- Record Components:
key- the placeholder string (e.g., "player", "amount").value- the content that will replace the placeholder.
A simple data carrier (Record) representing a placeholder and its replacement value.
This is used during text transformation to map specific keys to dynamic content.
- Since:
- 0.1
- Author:
- a8kj7sea
-
Constructor Summary
ConstructorsConstructorDescriptionReplacement(String key, String value) Creates an instance of aReplacementrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.key()Returns the value of thekeyrecord component.static ReplacementCreates a replacement from a raw object.static Replacementof(String key, Collection<String> collection) Creates a replacement from a collection of strings.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
of
Creates a replacement from a raw object. The object is converted to a string usingString.valueOf(Object).- Parameters:
key- the placeholder key.value- the object value.- Returns:
- a new
Replacementinstance.
-
of
Creates a replacement from a collection of strings. The elements are joined together using a newline character (\n). Useful for multi-line replacements like lists or messages.- Parameters:
key- the placeholder key.collection- the collection of strings to join.- Returns:
- a new
Replacementinstance.
-
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). -
key
Returns the value of thekeyrecord component.- Returns:
- the value of the
keyrecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-