Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7069065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:24:01+00:00 2026-05-28T05:24:01+00:00

I have public enum BaseActions implements Actions{ STAND (0,0,0), TURN (1,1,1); //other stuff }

  • 0

I have

public enum BaseActions implements Actions{
    STAND (0,0,0),
    TURN (1,1,1);
    //other stuff
}

public enum CoolActions implements Actions{
   STAND (0,2,3),
   TURN(1,6,9);
   //other stuff
}

public enum LooserActions implements Actions{
   STAND (0,-2,-3),
   TURN(1,-6,-9);
   //other stuff
}

public interface Actions {
       //interface methods
}

class A {
    Actions mCurrentAction;
    protected void notifyNewAction(final Actions pAction, final Directions pDirection){
         //body of the method
    }

    public void doStuff(final Actions pAction) {
         if(pAction.getMyId() > 0)
              notifyNewAction(BaseActions.STAND, myDirection);
         else
             notifyNewAction(BaseActions.TURN, myDirection);
    }
}

class B extends A{
     public void doMyStuff() {
           doStuff(CoolActions.STAND);
     }
}

class C extends A{
     public void doMyStuff() {
           doStuff(LooserActions.STAND);
     }
}

i would like to make A use CoolActions when doStuff is called from B and LooserActions when called from C.
One of the ways i think i can do it is to use generics, and then in B and C use

doStuff<CoolActions>(CoolActions.STAND)

and have in A

public void doStuff<T extends EnumActions&Actions>(final Actions pAction) {
             if(pAction.getMyId() > 0)
                  notifyNewAction(T.STAND, myDirection);
             else
                 notifyNewAction(T.TURN, myDirection);
        }

where EnumActions is a base enum that just contains the declaration of the enum’s elements, and nothing more, something like an interface for enums, but enums can’t extend another class since they already extends Enum, and an interface can’t provide what i mean.
Another way would be to make the enums implements a EnumActions interface that has

public interface EnumActions {
    public <T> T getStand();
    public <T> T getTurn();
}

and have

 class A {
        Actions mCurrentAction;
        protected void notifyNewAction(final Actions pAction, final Directions pDirection){
             //body of the method
        }

        public <T implements EnumActions> void doStuff(final Actions pAction) {
             if(pAction.getMyId() > 0)
                  notifyNewAction(T.getStand(), myDirection);
             else
                 notifyNewAction(T.getTrun(), myDirection);
        }
    }

and

public enum CoolActions implements Actions, EnumActions{
   STAND (0,2,3),
   TURN(1,6,9);
    public CoolActions getStand();
    public CoolActions getTurn();
   //other stuff
}

class B extends A{
     public void doMyStuff() {
           doStuff<CoolActions>(CoolActions.STAND);
     }
}

But 1)i don’t know if it would work 2) I lose the advanteges of using enums 3) this seams a really bad way to handle this 4) i would have to write a lot( X enum fields per Y different enums). I changed from static final fields to enum to improve readability and order, and this seams to make things even harder.

Am i designing this in the wrong way? How can i handle this?
Is there a preferred way to solve this problem?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:24:02+00:00Added an answer on May 28, 2026 at 5:24 am

    It seems like enums add nothing and are not going to do what you want. Maybe you should just use a normal class hierarchy – make BaseActions, CoolActions and LooserActions just classes that implement Actions and STAND and TURN methods in those classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following enum: public enum Status implements StringEnum{ ONLINE(on),OFFLINE(off); private String status
I have an enum: public enum Action { Remove=1, Add=2 } And a class:
I have this : [Flags] public enum InfoAbonne{civilite,name,firstname,email,adress,country } public class Formulaire { private
I have classes public class FooKeyedCollection : KeyedCollection<FooType,Foo> { } public enum FooType {
How to set Enums using reflection, my class have enum : public enum LevelEnum
Suppose that we have this class: public enum KindOfPerson { Student, Teacher, ... }
I have a class public abstract class AbstractE<T, E extends Enum<E> & Flags> {
i have enum public enum TypeImage { Img=0, Thumb=1 } i want in view
I have an enum public enum FileExtentions { mp3, mpeg } And I have
I have an enum: public enum baseKey : uint { HKEY_CLASSES_ROOT = 0x80000000, HKEY_CURRENT_USER

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.