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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:31:29+00:00 2026-06-07T01:31:29+00:00

I have an interface Schema , and another called SchemaParser . SimpleSchemaParser implements SchemaParser

  • 0

I have an interface Schema, and another called SchemaParser.
SimpleSchemaParser implements SchemaParser and SimpleSchema implements Schema.

SimpleSchemaParser has a method parseSchema() which returns a Schema. This way, SimpleSchemaParser.parseSchema() would return a Schema object. But I know that SimpleSchemaParser would always return a SimpleSchema. How should I change my design to make this apparent, rather than always having to cast the result to SimpleSchema? Should I go for generics in this case?

  • 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-07T01:31:31+00:00Added an answer on June 7, 2026 at 1:31 am

    You can indeed use generics, but they’re not required:

    class SchemaExample 
    {
        interface Schema 
        {
            // methods go here
        }
    
        interface SchemaParser 
        {
            Schema parseSchema();
        }
    
        class SimpleSchema implements Schema 
        {
            // implementation of Schema's methods
        }
    
        class SimpleSchemaParser implements SchemaParser 
        {
            @Override
            public SimpleSchema parseSchema() 
            {
                // real business logic here...
                return new SimpleSchema();
            }   
        }
    
        void usage() 
        {
            SimpleSchema schema = new SimpleSchemaParser().parseSchema();
        }
    }
    

    A slightly broader question is: why do you care which implementation of schema is returned? Are there methods that only exist on SimpleSchema? Can these move up to the interface Schema?

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

Sidebar

Related Questions

This has always bothered me... Let's say I have an interface IFiddle and another
I have created a schema as an agreed upon interface between our company and
I have two questions 1) my interface i have interface called IRegister and within
I'm trying to figure out why this code won't compile. I have interface A
I have an Interface like this: namespace QuickRoutes.Model.Utilities { public interface IRoutesManager { bool
I have next interface public interface IMyInterface { string this[string key] { get; set;
how can i check if an entity has a parent entity which maps this
I have layout included inside another layout , I want this included one aligned
I have recently being trying to create a project which has several levels of
We have a pretty complex BizTalk interface which uses the HL7 accelerator. We use

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.