Class DeserializedData<Data>

java.lang.Object
dev.prozilla.pine.core.component.Component
dev.prozilla.pine.core.component.deserialization.DeserializedData<Data>
Type Parameters:
Data - The type of data this component consumes
All Implemented Interfaces:
Destructible, Printable, ApplicationContext, ApplicationProvider, ComponentsContext, ComponentsProvider, EntityContext, EntityProvider, SceneContext, SceneProvider

public class DeserializedData<Data> extends Component
A component that consumes deserialized data from a JSON file.
  • Field Details

  • Constructor Details

    • DeserializedData

      public DeserializedData()
  • Method Details

    • readData

      public void readData(Directory directory, String fileName, Class<Data> dataType)
      Creates a file deserializer and reads data from it.

      If the application is in developer mode, hot reloading will be enabled.

      Parameters:
      directory - The directory of the file
      fileName - The name of the file
      dataType - The type of data to deserialize to
    • readData

      public void readData(Directory directory, String fileName, Class<Data> dataType, boolean hotReload)
      Creates a file deserializer and reads data from it.
      Parameters:
      directory - The directory of the file
      fileName - The name of the file
      dataType - The type of data to deserialize to
      hotReload - true enables hot reloading
    • readData

      public void readData(FileDeserializer<Data> deserializer)
      Reads the data from a file deserializer.

      This method can be used to initialize the component and create properties based on the data from the deserialized file.

      Parameters:
      deserializer - The file deserializer
    • getData

      public Data getData()
      Returns the deserialized data.
      Returns:
      The deserialized data.
    • destroy

      public void destroy()
      Destroys this component and its file deserializer.
      Specified by:
      destroy in interface Destructible
      Overrides:
      destroy in class Component