Record Class Property<T>
java.lang.Object
java.lang.Record
org.teleight.teleightbots.conversation.Property<T>
- Type Parameters:
T- the type of the property value.- Record Components:
name- the name of the property. Cannot be null.value- the value of the property.required- whether the property is required or not.
Represents a custom property that can be used in a conversation.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<A> AReturns the value of the property as a custom type.booleanasBool()Returns the value of the property as a boolean.floatasFloat()Returns the value of the property as a double.intasInt()Returns the value of the property as an integer.longasLong()Returns the value of the property as a long.asString()Returns the value of the property as a string.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Stringname()Returns the value of thenamerecord component.Creates a new property with the given name.static <T> Property<T> Creates a new property with the given name and value.booleanrequired()Returns the value of therequiredrecord component.final StringtoString()Returns a string representation of this record class.value()Returns the value of thevaluerecord component.
-
Constructor Details
-
Method Details
-
of
Creates a new property with the given name. The returned property will have a null value and will be required.- Parameters:
name- the name of the property. Cannot be null.- Returns:
- a new property with the given name.
-
of
Creates a new property with the given name and value.- Parameters:
name- the name of the property. Cannot be null.value- the value of the property.- Returns:
- a new property with the given name and value.
-
asString
Returns the value of the property as a string.- Returns:
- the value of the property as a string.
-
asInt
public int asInt()Returns the value of the property as an integer.- Returns:
- the value of the property as an integer.
- Throws:
ClassCastException- if the value cannot be cast to an integer.
-
asBool
public boolean asBool()Returns the value of the property as a boolean.- Returns:
- the value of the property as a boolean.
- Throws:
ClassCastException- if the value cannot be cast to a boolean.
-
asLong
public long asLong()Returns the value of the property as a long.- Returns:
- the value of the property as a long.
- Throws:
ClassCastException- if the value cannot be cast to a long.
-
asFloat
public float asFloat()Returns the value of the property as a double.- Returns:
- the value of the property as a double.
- Throws:
ClassCastException- if the value cannot be cast to a double.
-
as
Returns the value of the property as a custom type.- Returns:
- the value of the property as a custom type.
- Throws:
ClassCastException- if the value cannot be cast to a custom type.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
value
Returns the value of thevaluerecord component.- Returns:
- the value of the
valuerecord component
-
required
public boolean required()Returns the value of therequiredrecord component.- Returns:
- the value of the
requiredrecord component
-