java.lang.Object
com.minecolonies.api.colony.requestsystem.factory.standard.TypeTokenFactory
All Implemented Interfaces:
IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>

public class TypeTokenFactory extends Object implements IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.common.reflect.TypeToken<?>
    deserialize(IFactoryController controller, net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Method to deserialize a given constructable.
    @NotNull com.google.common.reflect.TypeToken<?>
    deserialize(net.minecraft.core.HolderLookup.Provider provider, @NotNull IFactoryController controller, @NotNull net.minecraft.nbt.CompoundTag nbt)
    Method to deserialize a given constructable.
    @NotNull com.google.common.reflect.TypeToken<? extends Class<?>>
    Used to determine which type this can produce.
    @NotNull com.google.common.reflect.TypeToken<? extends com.google.common.reflect.TypeToken<?>>
    Method to get the type this factory can produce.
    @NotNull com.google.common.reflect.TypeToken<?>
    getNewInstance(@NotNull IFactoryController factoryController, @NotNull Class<?> aClass, @NotNull Object... context)
    Method to get a new instance of the output given the input and additional context data.
    short
    Get a serialization id for the factory.
    void
    serialize(IFactoryController controller, com.google.common.reflect.TypeToken<?> input, net.minecraft.network.RegistryFriendlyByteBuf packetBuffer)
    Method to serialize a given constructable.
    @NotNull net.minecraft.nbt.CompoundTag
    serialize(net.minecraft.core.HolderLookup.Provider provider, @NotNull IFactoryController controller, @NotNull com.google.common.reflect.TypeToken<?> typeToken)
    Method to serialize a given constructable.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TypeTokenFactory

      public TypeTokenFactory()
  • Method Details

    • getFactoryOutputType

      @NotNull public @NotNull com.google.common.reflect.TypeToken<? extends com.google.common.reflect.TypeToken<?>> getFactoryOutputType()
      Description copied from interface: IFactory
      Method to get the type this factory can produce.
      Specified by:
      getFactoryOutputType in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Returns:
      The type of request this factory can produce.
    • getFactoryInputType

      @NotNull public @NotNull com.google.common.reflect.TypeToken<? extends Class<?>> getFactoryInputType()
      Description copied from interface: IFactory
      Used to determine which type this can produce.
      Specified by:
      getFactoryInputType in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Returns:
      The class that represents the Type of Request this can produce.
    • getNewInstance

      @NotNull public @NotNull com.google.common.reflect.TypeToken<?> getNewInstance(@NotNull @NotNull IFactoryController factoryController, @NotNull @NotNull Class<?> aClass, @NotNull @NotNull Object... context) throws IllegalArgumentException
      Description copied from interface: IFactory
      Method to get a new instance of the output given the input and additional context data.
      Specified by:
      getNewInstance in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Parameters:
      factoryController - The controller calling this factory method.
      aClass - The input to build a new output for.
      context - The context of the request.
      Returns:
      The new output instance for a given input.
      Throws:
      IllegalArgumentException - is thrown when the factory cannot produce a new instance out of the given context and input.
    • serialize

      @NotNull public @NotNull net.minecraft.nbt.CompoundTag serialize(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull IFactoryController controller, @NotNull @NotNull com.google.common.reflect.TypeToken<?> typeToken)
      Description copied from interface: IFactory
      Method to serialize a given constructable.
      Specified by:
      serialize in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Parameters:
      controller - The controller that can be used to serialize complicated types.
      typeToken - The request to serialize.
      Returns:
      The serialized data of the given requets.
    • deserialize

      @NotNull public @NotNull com.google.common.reflect.TypeToken<?> deserialize(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull IFactoryController controller, @NotNull @NotNull net.minecraft.nbt.CompoundTag nbt) throws Throwable
      Description copied from interface: IFactory
      Method to deserialize a given constructable.
      Specified by:
      deserialize in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Parameters:
      controller - The controller that can be used to deserialize complicated types.
      nbt - The data of the request that should be deserialized.
      Returns:
      The request that corresponds with the given data in the nbt
      Throws:
      Throwable
    • serialize

      public void serialize(IFactoryController controller, com.google.common.reflect.TypeToken<?> input, net.minecraft.network.RegistryFriendlyByteBuf packetBuffer)
      Description copied from interface: IFactory
      Method to serialize a given constructable.
      Specified by:
      serialize in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Parameters:
      controller - The controller that can be used to serialize complicated types.
      input - The request to serialize.
      packetBuffer - The buffer to serialize into.
    • deserialize

      public com.google.common.reflect.TypeToken<?> deserialize(IFactoryController controller, net.minecraft.network.RegistryFriendlyByteBuf buffer) throws Throwable
      Description copied from interface: IFactory
      Method to deserialize a given constructable.
      Specified by:
      deserialize in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Parameters:
      controller - The controller that can be used to deserialize complicated types.
      buffer - The data buffer of the request that should be deserialized.
      Returns:
      The request that corresponds with the given data in the nbt
      Throws:
      Throwable
    • getSerializationId

      public short getSerializationId()
      Description copied from interface: IFactory
      Get a serialization id for the factory.
      Specified by:
      getSerializationId in interface IFactory<Class<?>,com.google.common.reflect.TypeToken<?>>
      Returns:
      the short id.