Class AbstractSpecification<A,B>

java.lang.Object
com.pixelmonmod.api.AbstractSpecification<A,B>
Type Parameters:
A - The reforged data type
B - The minecraft data type
All Implemented Interfaces:
Specification<A,B>, Cloneable
Direct Known Subclasses:
CardSpecification, PokemonSpecification, StatueSpecification

public abstract class AbstractSpecification<A,B> extends Object implements Specification<A,B>
Abstract implementation of the specification interface that handles all the logic for the sub-classes Meaning the sub classes just have to pass in the data types
  • Field Details

    • dataType

      protected final Class<A> dataType
    • minecraftType

      protected final Class<B> minecraftType
    • originalSpec

      protected final String originalSpec
    • requirements

      protected final List<Requirement<A,B,?>> requirements
  • Constructor Details

  • Method Details

    • matches

      public boolean matches(Object o)
      Description copied from interface: Specification
      Checks if an object matches the specification data Will return false if the object is neither A or B
      Specified by:
      matches in interface Specification<A,B>
      Parameters:
      o - The object being checked
      Returns:
      True if it matches the data - false otherwise
    • apply

      public void apply(Object o)
      Description copied from interface: Specification
      Applies the specification data to the given object Will do nothing if the object is not of type A or B
      Specified by:
      apply in interface Specification<A,B>
      Parameters:
      o - The object being updated
    • getValue

      public <T> Optional<T> getValue(Class<? extends Requirement<A,B,T>> clazz)
      Description copied from interface: Specification
      Attempts to get a value from the specification Will return Optional.empty() if not found
      Specified by:
      getValue in interface Specification<A,B>
      Type Parameters:
      T - The type of the requirement
      Parameters:
      clazz - The data type being searched for
      Returns:
      Any found data
    • getRequirement

      public <T> Optional<Requirement<A,B,T>> getRequirement(Class<? extends Requirement<A,B,T>> clazz)
      Description copied from interface: Specification
      Attempts to get a requirement from the specification Will return Optional.empty() if not found
      Specified by:
      getRequirement in interface Specification<A,B>
      Type Parameters:
      T - The type of the requirement
      Parameters:
      clazz - The data type being searched for
      Returns:
      Any found data
    • getRequirements

      public <T> Set<Requirement<A,B,T>> getRequirements(Class<? extends Requirement<A,B,T>> clazz)
      Description copied from interface: Specification
      Attempts to get a list of requirements from the specification
      Specified by:
      getRequirements in interface Specification<A,B>
      Type Parameters:
      T - The type of the requirement
      Parameters:
      clazz - The data type being searched for
      Returns:
      Any found data
    • write

      public net.minecraft.nbt.CompoundTag write(net.minecraft.nbt.CompoundTag nbt)
      Description copied from interface: Specification
      Writes the specification to NBT
      Specified by:
      write in interface Specification<A,B>
      Parameters:
      nbt - The NBT being written to
      Returns:
      The updated NBT
    • toString

      public String toString()
      Overrides:
      toString in class Object