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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:52:37+00:00 2026-06-01T16:52:37+00:00

I have at least two different classes like following : //NOTE : these two

  • 0

I have at least two different classes like following :

//NOTE : these two classes have getter and setter also
class Artist {

String artistName;
String artistWebsite;
String artistDbpedia;
String artistImage;
List<String> astistAlbumsName;
List<String> astistAlbumsUrl;
}

class Venu {
String VenuName;
String VenuWebsite;
String VenuDbpdia;
String VenuImage;
String VenuDescription;
List<String> venuFans;
}

I want to have a producer class to get an xml file as an input and detect the type of xml (venu/artist) then start to create a product object based on the input.

the problem :

I want to create an interface for aggregate the similarity between above two classes so my interface would be:

interface Model {
public String getImage();
public String getName();
public String getWebsite();
public String getdbpedia();
}

Then I can implement this interface in my builder class and above two classes but how about those different methods?

such as getVenuFans / getArtistAlbumName / etc….?

How can I call them from my producer?

this is my builder :

Class Builder implements Model {
public String getImage(){}
public String getName(){}
public String getWebsite(){}
public String getdbpedia(){}
}

and this can be my producer :

Class Producer {
public Producer()
{
Builder b = null;
//assume Venu and Artist implements Model
b = (Builder) new Venu();
//I don't have access to getVenuFans()!

b = (Builder) new Artist();
//I don't have access to getArtistAlbumsName() / etc...

}
}
  • 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-01T16:52:38+00:00Added an answer on June 1, 2026 at 4:52 pm

    You don’t have access to those methods because you’re casting the objects to a Builder, and Builder doesn’t have those methods.

    I see what you’re trying to do, but I don’t think it will work. For example, getVenueFans (I’m assuming you mean venue) is only appropriate for the Venue class. It doesn’t make sense to try and abstract that into an interface that other non-Venue classes will implement.

    I think what you have is good: You’ve abstracted the common methods into an interface. To call the methods on Venue and Artist, the consuming code will need to cast the objects to the appropriate type, then call the methods on it. And that’s not as bad as you might think. It’s the consuming code that knows what type it’s dealing with (otherwise, why would it be trying to call getVenueFans?), so that’s the point where it makes sense to cast and call the method directly.

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

Sidebar

Related Questions

Let's say I have the following two classes: package example.model; public class Model {
I have two ActiveRecord classes. A simplified view of these classes: class Account <
I have a form with (at least) the following two fields: country club The
I have two classes defined as such: public class Questionnaire { public int QuestionnaireID
I have a some classes which I need to serialize in two different ways:
I am trying to get at least three words separated by two commas.I have
I have two tables, name and address. I would like to list the last_name
I have two functions that are very similar and i'd like to make a
Assume two different scenarios: a) Each (service) class X has an interface X and
Suppose I have an abstract base class BaseTimeCollection and at least one concrete class

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.