Package Executable

Class ClassList<X,​Y>

  • Type Parameters:
    X - The type of the input to the constructor
    Y - The super class of the classes to be constructed

    public class ClassList<X,​Y>
    extends java.lang.Object
    Represents a map of constructors so that a new object of the appropriate child class (given by a string) can be constructed. All constructors must have the same type of single input. Not the best description - probably best to see how it's used!
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassList()
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String type, java.util.function.Function<X,​Y> constructor)
      Add a new child class
      Y get​(java.lang.String type, X parameters)
      Get a new instance of the child class
      boolean has​(java.lang.String type)
      Whether the class list has a class associated with a string
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassList

        public ClassList()
        Default constructor
    • Method Detail

      • add

        public void add​(java.lang.String type,
                        java.util.function.Function<X,​Y> constructor)
        Add a new child class
        Parameters:
        type - The string representing the child class
        constructor - The constructor for that class
      • get

        public Y get​(java.lang.String type,
                     X parameters)
        Get a new instance of the child class
        Parameters:
        type - The string representing the child class
        parameters - The input parameter to the constructor
        Returns:
        The new child class object
      • has

        public boolean has​(java.lang.String type)
        Whether the class list has a class associated with a string
        Parameters:
        type - The string
        Returns:
        Whether there is a class associated with it