Class Factory<T>

java.lang.Object
me.deecaad.weaponmechanics.utils.Factory<T>
Direct Known Subclasses:
ExposureFactory, ShapeFactory

public class Factory<T> extends Object
  • Constructor Details

    • Factory

      protected Factory(@NotNull @NotNull Class<T> clazz)
      Only subclasses should be able to instantiate this class. It does not make sense to instantiate a factory otherwise.
  • Method Details

    • get

      public final T get(@NotNull @NotNull String key, @NotNull @NotNull Map<String,Object> arguments) throws me.deecaad.core.file.SerializerException
      Returns a constructed object of who inherits from T, constructed from the given arguments. In order to add a new type, use set(String, Arguments).

      The given arguments MUST explicitly contain ALL objects defined by the Factory.Arguments.arguments. If an argument is missing, a SerializerException is thrown. The given objects are type-casted to their expected type. Ensure that the constructors for your defined arguments exist.

      Parameters:
      key - The non-null, non-case-sensitive name of the class to instantiate.
      arguments - The non-null map of arguments.
      Returns:
      Instantiated object.
      Throws:
      InternalError - If no "good" constructor exists.
      me.deecaad.core.file.SerializerException - invalid key OR missing argument OR invalid argument type.
    • set

      public final void set(@NotNull @NotNull String key, @NotNull Factory<T>.@NotNull Arguments args)
    • getOptions

      @NotNull public @NotNull Set<String> getOptions()
    • getMap

      @NotNull public @NotNull Map<String,Class<T>> getMap()