Solved Interface that will create an enum

Discussion in 'Plugin Development' started by ItsComits, Feb 12, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    ItsComits

    Hello, I am wanting to use an interface that will create an enum in the class that implements the interface. I am just looking for a push into the right direction on how I would accomplish this.
     
  2. Offline

    Lorinthio

    Need a little bit more detail or an example.

    From the first read, it sounds like you should use an Abstract class which you can extend to other classes.

    Code:
    public abstract class EnumeratedSuper{
        public enum SomeEnumerator{
            First, Second, Third
        }
    }
    
    public class SomeClass extends EnumeratedSuper{
      
        private SomeEnumerator enumSelected;
      
        public SomeClass(){
            enumSelected = SomeEnumerator.First;
        }
    }

    On my third read, sounds like you need something like an Animal super class that contains an enumerator of all Animal subclasses?
     
  3. Offline

    ItsComits

    @Lorinthio
    Here is what I am trying to achieve.
    Code:
        public interface interfaceClass {
            //Stuck here
        }
       
        public class someClass implements interfaceClass {
    
            //Wanting to generate an empty enum with some methods
            public enum enumName {
               
                public getName() {
                    return this.name();
                }
               
            }
     
  4. Offline

    Lorinthio

    @ItsComits

    Don't think I have enough knowledge with how you are trying to structure it to help.

    I guess another question would be what are you trying to accomplish with this? Might be a different way to approach it that I could help with :)
     
  5. Offline

    ItsComits

    @Lorinthio Im using the enums for each database. Each database will have different actions depending on what data is going to be stored within the database. I am wanting to use the enums so that I will be able to use these database actions elsewhere in the plugin.
     
  6. Offline

    RcExtract

    So i assume you are trying to use enums to declare which saving action should be used to store an object into a database, probably with serialization. But how is it related to interfaces? I dont understand what u are trying to achieve, plz explain more.
     
  7. Offline

    Horsey

    Sounds like the XY problem.

    What exactly are you trying to achieve with this enum/interface thing?
     
    Last edited: Feb 16, 2018
    Lorinthio likes this.
Thread Status:
Not open for further replies.

Share This Page