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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:05:55+00:00 2026-06-05T07:05:55+00:00

Consider that object wrapped in DataContainer will be handed out to client // Will

  • 0

Consider that object wrapped in DataContainer will be handed out to client

// Will be handed out
public interface DataContainer 

In order to use it, client currently needs to know to cast the object to:

public interface ConcreteObject_1_Container extends DataContainer
public interface ConcreteObject_2_Container extends DataContainer

Is it possible to offer both ConcreteObject1Container and ConcreteObject2Container as options to be chosen from, similar to how Enum options can be picked?

Instead of user magically knowing to use FileContainer

                                   // user knows
FileContainer   fileContainer   = (FileContainer) 
                ContainerFactory.getContainerFor(DataSource.FILE, 
                                                 TREAT_AS_SOURCE);

I’d like to

                                  // user selects
FileContainer   fileContainer   = (GenericContainer.FileContainer) 
                ContainerFactory.getContainerFor(DataSource.FILE, 
                                                 TREAT_AS_SOURCE); 
  • 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-06-05T07:05:56+00:00Added an answer on June 5, 2026 at 7:05 am

    You should probably change your design. Either:

    1. the client just uses the methods on DataContainer, without caring what implementation it is, in which case the cast can be avoided, or
    2. the client is actually coupled to the implementation, so should just use the implementation types directly (e.g. with two different methods)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider Object obj = ....; System.out.println(obj instanceof Object); What should obj be so that
Consider that I have 100 instances of a squeaker class. Each squeaker object is
The question is asked with respect to an Object DataSource. So Consider that I
Consider situation when we have a class with couple of static methods that use
Consider that you get this JSON object: { id: 3, name: 'C' } How
Consider that I've a excel sheet in below format: person age Foo 29 Bar
Consider that there is a bunch of tables which link to countries or currencies
Consider that I have 1 resource and 2 urls (let's say new one and
hai consider that my application name is sApp.exe when i run my application as
I am preparing for my interview and came across this question: Consider that i

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.