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

public abstract class PropertyData<T> extends Object
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).
  • Constructor Details

    • PropertyData

      protected PropertyData(String name)
      The sole constructor.
      Parameters:
      name - Name of the future property object.
  • Method Details

    • getName

      public final String getName()
      Returns:
      The name of this property.
    • getPrefixedName

      public 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. 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

      @Nonnull public abstract T 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

      public abstract String toString(Object value)
      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

      public abstract T parseObj(com.google.gson.JsonElement value)
      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

      public abstract JComponent getComponent(MCreator mcreator, @Nullable Object value)
      Generates a UI component accepting values of type PropertyData 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

      public abstract T getValue(JComponent component)
      Extracts possible value of this property from the provided UI component.
      Parameters:
      component - A UI component that accepts values of type PropertyData.
      Returns:
      A value of this property's type.
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public final String toString()
      Overrides:
      toString in class Object