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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:06:23+00:00 2026-05-29T15:06:23+00:00

In my project I have two chunk of code which I would like to

  • 0

In my project I have two chunk of code which I would like to separate to make one part a library. Yesterday, when I was trying to separate it I notice that there is a very strong connection between my new library and my application layer which is caused by Enum type. Of course I could simply change that Enum into the primary type of int, or a String and by this enabling myself to define those values within the application layer, but by doing it I would get rid of the type-check mechanism which I would like to have. Is there any other way to achieve it without loosing the type checking mechanism of Java/Android?
And the issue:

Application Layer

Enum Id {…} // how to generalize the type?

Library Layer

SomeClass.someMethod(Id myResource) {…}

  • 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-29T15:06:24+00:00Added an answer on May 29, 2026 at 3:06 pm

    Don’t use an enum in your library. Use an interface, that the application will have to implement the way it wants to (by using an enum, for example).

    The interface should contain the methods that are needed by the library. Without a more concrete example, it’s hard to provide a more concrete answer.

    For example:

    public interface Identifiable {
        /**
         * returns the ID of the resource, that must unique among all the resources
         */
        public String getId();
    }
    
    public class SomeClass
        public void someMethod(Identifiable identifiable) {
            // some code that uses identifiable.getId()
        }
    }
    

    And in the application:

    public enum Id implements Identifiable {
        FOO,
        BAR;
    
        @Override
        public String getId() {
            return name();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two projects at google code. I would like to have the first
I have two project, one which generates some artifacts from a WSDL file using
I have a project where I would like to create two session cookies in
I have two applications in my project 'test' the applications are one.mxml and two.mxml
I have two checkouts of one trunk of a project via SVN. One is
Suppose I have two branches of a project IMClient-MacOS and IMClient-Windows, and their code
I have two projects, the DLL project which has all my logic and data
Within a c# project I have two collections and I am trying to query
I'm working on trying to have my project automatically build two different versions of
I have two same project in which I have two classes under same namespace

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.