Record Class StringValue
java.lang.Object
java.lang.Record
com.github.siroshun09.configapi.core.node.StringValue
- Record Components:
value
- aString
value
- All Implemented Interfaces:
Node<String>
,StringRepresentable
,ValueNode<String>
public record StringValue(@NotNull String value)
extends Record
implements ValueNode<String>, StringRepresentable
-
Field Summary
Modifier and TypeFieldDescriptionstatic final StringValue
AStringValue
that represents an empty string. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NotNull VisitResult
accept
(@NotNull NodeVisitor visitor) Accepts aNodeVisitor
for thisNode
.@NotNull String
asString()
Gets the value asString
.final boolean
Indicates whether some other object is "equal to" this one.static @NotNull StringValue
fromString
(@NotNull String value) Creates aStringValue
from the given string or returnsEMPTY
if the given string is empty.final int
hashCode()
Returns a hash code value for this object.boolean
hasValue()
Checks if thisNode
holds an object.final String
toString()
Returns a string representation of this record class.@NotNull String
value()
Returns the value of thevalue
record component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.github.siroshun09.configapi.core.node.Node
asOptional
-
Field Details
-
EMPTY
AStringValue
that represents an empty string.
-
-
Constructor Details
-
StringValue
A constructor ofStringValue
.- Parameters:
value
- aString
value
-
-
Method Details
-
fromString
Creates aStringValue
from the given string or returnsEMPTY
if the given string is empty.- Parameters:
value
- aString
value- Returns:
- a
StringValue
-
hasValue
public boolean hasValue()Description copied from interface:Node
Checks if thisNode
holds an object.The default implementation of this method checks if the returning value from
Node.value()
is notnull
. -
accept
Description copied from interface:Node
Accepts aNodeVisitor
for thisNode
.- Specified by:
accept
in interfaceNode<String>
- Parameters:
visitor
- aNodeVisitor
to accept- Returns:
- a
VisitResult
-
asString
Gets the value asString
.- Specified by:
asString
in interfaceStringRepresentable
- Returns:
- the value as
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. -
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)
. -
value
Returns the value of thevalue
record component.
-