permaculture playing cards*
The moose likes Java in General and the fly likes Generics with methods for specific types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generics with methods for specific types" Watch "Generics with methods for specific types" New topic
Author

Generics with methods for specific types

Chinababu Illa
Greenhorn

Joined: Jun 04, 2008
Posts: 23
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
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 370
    
    1

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..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics with methods for specific types
 
Similar Threads
Overriding private & final methods
wildcard type parameter
Generics question
Interface combinations ...
Generifying a class - unchecked cast