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 4597126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:12:45+00:00 2026-05-21T23:12:45+00:00

I need to hide some menu options in the production environment, but not in

  • 0

I need to hide some menu options in the production environment, but not in development.

I implemented this as an enum like this:

public enum Functionality {
    FUNCTION_1(true),
    FUNCTION_2,
    FUNCTION_3(true);

    private boolean usable;

    Functionality() {
        this(false);
    }

    Functionality(boolean usable) {
        this.usable = usable;
    }

    public boolean isUsable() {
        return usable;
    }
}

And then, when I need to show the menu options, I check whether that functionality needs to be shown.

So I need to be able to change the usable boolean when the environment is development. But I cannot find any way to do it in Spring.

Do you know of a way to do something like this?

  • 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-21T23:12:46+00:00Added an answer on May 21, 2026 at 11:12 pm

    You could change the fields of an enum, but it’s usually considered a bad idea and is often a design smell.

    A better approach would possibly be to not have usable be a field at all, instead make it a calculated property:

    public enum Functionality {
        FUNCTION_1(true),
        FUNCTION_2,
        FUNCTION_3(true);
    
        private final boolean restricted;
    
        Functionality() {
           this(false);
        }
    
        Functionality(boolean restricted) {
            this.restricted = restricted;
        }
    
        public boolean isRestricted() {
            return restricted;
        }
    
        public boolean isUsable() {
            if (!restricted) {
                return true;
            } else {
                return SystemConfiguration.isDevelopmentSystem();
            }
        }
    }
    

    Obviously there would need to be a method like SystemConfiguration.isDevelopmentSystem() for this to work.

    In some systems I implemented I used another enum for this:

    public enum SystemType {
        PRODUCTION,
        TESTING,
        DEVELOPMENT;
    
        public final SystemType CURRENT;
    
        static {
            String type = System.getEnv("system.type");
            if ("PROD".equals(type)) {
                CURRENT = PRODUCTION;
            } else if ("TEST".equals(type)) {
                CURRENT = TESTING;
            } else {
                CURRENT = DEVELOPMENT;
            }
        }
    }
    

    Here I used a system property to specify the type at runtime, but any other configuration type might be just as appropriate.

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

Sidebar

Related Questions

Possible Duplicate: how to hide a div after some time period? i need to
i need to hide a windows program (not visible in taskbar, system tray. visible
I have one web page where i need to hide some images , some
I'm not so good at JS and I need some help I'm trying to
I implemented some code (below) to check the state of ContentID and hide or
I'm new to jQuery and need some help to show and hide a div
I need to hide some text (Add £0.20) which is within a td. I
I'm not sure how to describe what I need but I'll give it a
Using validateUserInterfaceItem it is possible to disable/enable a menu item but I need a
We need to hide some of the built-in field of our Pages in the

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.