Solved Multiple queues for multiple enums

Discussion in 'Plugin Development' started by ItsComits, Oct 29, 2017.

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

    ItsComits

    Hello, I trying to create a queue(Queue<K>) for each enum. How would I go about doing this without creating each queue separately and having allotted of setters and getters? Any help is appreciated
     
  2. Offline

    MightyOne

    i dont think there is not any other way than initializing every queue manually. But i dont understand yet what you mean with alot of getters and setters? or do you mean you would like to put all queues in a list?
     
  3. Offline

    ItsComits

    @MightyOne I do not want to create a getter and a setter to get the queue from the class. I want to be able to access it by using the enum. Like this, Class.SomeEnum.Queue. Is this possible and how?
     
  4. Offline

    MightyOne

    yeah make a static queue? I am not sure what enums are able to do xD but i guess a public static queue should be possible. but maybe make a getter for it anyway?
     
  5. Offline

    ItsComits

    @MightyOne I have this so far. But I cannot use MyEnum.A.getQueue();
    Here is the code:
    Code:
        public enum myEnum {
            A {
                Queue<K> A_QUEUE = new LinkedList<K>();
    
                public Queue<Arena> getQueue() {
                    return A_QUEUE;
                }
    
            }
        }
     
  6. Offline

    Caderape2

    @ItsComits
    Code:
        public enum myEnum
        {
            A, B, C;
          
            private Queue<K> queue;
          
            private myEnum()
            {
                queue = new LinkedList<K>();
            }
          
          
            public Queue<K> getQueue()
            {
                return queue;
            }
        }
    
    This will create a Queue by enum.
    myEnum.A.getQueue();
     
  7. Offline

    ItsComits

    Thanks for this. I was thinking about creating a method for each enum(Overthinking). Anyways thank you both for your help :D @MightyOne @Caderape2
     
  8. Offline

    MightyOne

    Ok cool i guess i learned something as well.
     
Thread Status:
Not open for further replies.

Share This Page