enum

Discussion in 'Spigot Plugin Development' started by TheFuzzyHead5, Jun 1, 2017.

  1. so I have a Class in an enum

    for example:

    TEST_ENUM(MyClass);

    private Class instance;
    private EnumClass(Class instance) {
    this.instance = instance;
    }


    public Class getInstance() { return instance; }


    From outside the enum I can access the class, but this is confusing me.. how do I create an instance of it? What do I do with it?

    When I simply do EnumClass.TEST_ENUM.getInstance() I cannot then use this class how I wish.
     
  2. Create an instance of? MyClass? You could use reflection to instantiate it, or use a Supplier (which would be faster)
     
    • Agree Agree x 3
  3. I vote supplier!
     
    • Agree Agree x 1
  4. you probably also vote inline to do it, dont you?