Package net.mcreator.ui.minecraft.states
Class PropertyData<T>
java.lang.Object
net.mcreator.ui.minecraft.states.PropertyData<T>
- Type Parameters:
T
- Type of values this property can take.
- Direct Known Subclasses:
PropertyData.IntegerType
,PropertyData.LogicType
,PropertyData.NumberType
,PropertyData.StringType
Instances of this class store information about certain property (its name, type,
minimum and maximum values for number properties, list of allowed values for string properties and so on).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A subclass for integer number type properties.static class
A subclass for boolean type properties.static class
A subclass for fractional number type properties.static class
A subclass for string type properties. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
abstract JComponent
getComponent
(MCreator mcreator, Object value) Generates a UI component accepting values of typePropertyData
and sets its value to the passed one.abstract T
Provides the default value of type of this property.final String
getName()
final String
getPrefixedName
(String prefix) Adds the prefix to the name of this property if it is not a built-in property and returns the result.abstract T
getValue
(JComponent component) Extracts possible value of this property from the provided UI component.final int
hashCode()
abstract T
parseObj
(com.google.gson.JsonElement value) Parses string representation of passed value of this property.final String
toString()
abstract String
Converts passed value of this property to its string representation.
-
Constructor Details
-
PropertyData
The sole constructor.- Parameters:
name
- Name of the future property object.
-
-
Method Details
-
getName
- Returns:
- The name of this property.
-
getPrefixedName
Adds the prefix to the name of this property if it is not a built-in property and returns the result. Can be used for cases where property names need to be unique across multiple mod elements that could define property with the same name.- Parameters:
prefix
- Prefix to add to the name- Returns:
- The name of this property with the prefix
-
getDefaultValue
Provides the default value of type of this property. This is the "null" value of this type, which means it may be outside value limits defined for a particular property.- Returns:
- A default value of this property's type.
-
toString
Converts passed value of this property to its string representation.- Parameters:
value
- A value of this property's type.- Returns:
- Possible value of this property as a string.
- Throws:
ClassCastException
- if the type of passed value doesn't match the type of property or its subtype.
-
parseObj
Parses string representation of passed value of this property.- Parameters:
value
- Possible value of this property as JsonElement.- Returns:
- A value of this property's type.
-
getComponent
Generates a UI component accepting values of typePropertyData
and sets its value to the passed one.- Parameters:
mcreator
- The future parent window of the component returned.value
- Possible value of this property.- Returns:
- A UI component that accepts values of type
PropertyData
. - Throws:
ClassCastException
- if the type of passed value doesn't match the type of property or its subtype.
-
getValue
Extracts possible value of this property from the provided UI component.- Parameters:
component
- A UI component that accepts values of typePropertyData
.- Returns:
- A value of this property's type.
-
equals
-
hashCode
public final int hashCode() -
toString
-