Results 1 to 5 of 5
Thread: Class cast
- 02-23-2012, 09:04 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Class cast
Hi,
I'm searching for a way to cast between two class entities. I'm writing a CRM with Target and Lead classes. Both are subclasses from BaceContact class each with additional fields.
I have to somehow cast between them. Is it the only way to set manually all the fields from Target to Lead?
I'd also like to keep the same key if possible, so all the documents attached to Target can will be preserved. From my point of view Target can be removed from the table.
-
Re: Class cast
What do you mean by "cast between them"? Please provide some details.
- 02-23-2012, 09:56 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Re: Class cast
Hi,
I have to convert (better as cast) from Target to Lead. As Target and Lead use same superclass BaseContact. Now - I would like to write method, which would convert a Target to a Lead.
I have several dependent entities like Attachments, which are connected directly to BaseContact superclass. My process should remove Target and convert it into a Lead, keeping an id of the Target, so all the dependent entities does not need to change.
-
Re: Class cast
Well the casting part is easy -- you can't do it so don't try. But the other issues sound as if it may be best solved via one or more design patterns. Perhaps you can create a class that has holds the basic data and has the basic shared behaviors of both Target and Lead, and use a Command Pattern and perhaps dependency injection to swap in and out modules that allow the class to exhibit Target or Lead behaviors.
- 02-23-2012, 10:27 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Need Help with Class Cast Exception
By soxfan714 in forum New To JavaReplies: 2Last Post: 11-03-2011, 04:33 PM -
Class Cast exception
By henry123 in forum Advanced JavaReplies: 4Last Post: 02-15-2011, 11:42 AM -
Class cast issue
By AedonetLIRA in forum New To JavaReplies: 5Last Post: 11-19-2010, 04:34 PM -
Cast own class to FrameView
By Luxpsycho in forum AWT / SwingReplies: 0Last Post: 07-16-2010, 10:13 AM -
class cast exception
By venkatallu in forum New To JavaReplies: 2Last Post: 09-02-2008, 09:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks