• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Generics with methods for specific types

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a class and another class

I need a method to retrieve some of the properties of XType and those properties are not available in BaseType. So that this method is not generic for both the types and is specific only to XType. This is the only method which is specific to XType, and rest all are generic methods, which convinced me to have generic class.
Is there any way, such that I can make this method visible only for the and not visible for the

Thanks,
Chinna
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you need a different class(Format) at all to do what you need??
You can simply have the methods(which you are calling generic) in your BaseType class and
the methods which are specific to XType will be in that class only..

The problem what you are stating is of Basic Inheritance and Dynamic Binding, rather than of Generics..
 
Marshal
Posts: 76872
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question is confusing, which suggests to me your inheritance design is confusing, too. I suspect the best thing to do is go back and look at the hierarchy (as RJ has already suggested) and consider whether XType extends BaseType is the best inheritance to use.
 
catch it before it slithers away! Oh wait, it's a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic