|
|
|
|
Re: specialization [message #714769 is a reply to message #714768] |
Thu, 11 August 2011 12:42 |
Eclipse User |
|
|
|
Originally posted by:
I don't think you can override the default value. What you could do is
to model it as a derived feature and implement the corresponding get
method in the subclass' implementation. That way the values may differ
and you still access it as a "normal" attribute.
hallvard
On 11.08.11 14.36, Daniel Winkels wrote:
> Am 11.08.11 14:18, schrieb Daniel Winkels:
>> Hello Ed,
>>
>> i assumed that the question is somehow unclear. I uploaded an image
>> with a small example of what i am intending to do.
>> I just explain it:
>>
>> "DialogElement" is the abstract common base of "File" and "Date".
>> There will be no instance of "DialogElement" but of its children. All
>> I want to do is set the field "type" = "DateField" or "type" =
>> "FileField" according to the Class of the instance. There will be no
>> need to change the value again, so it can be set statically or on
>> initialization time. I just do not know how to assign static or
>> default values in a subclass to a field that is modeled in the
>> superclass.
>>
>> I hope it is getting clearer :)
>
> I just saw that my image is wrong. The superclass of Date should be
> DialogElement.
|
|
|
Re: specialization [message #714772 is a reply to message #714769] |
Thu, 11 August 2011 13:03 |
Daniel Winkels Messages: 19 Registered: October 2010 |
Junior Member |
|
|
Hello Hallvard,
this sounds like a pretty good solution, even though i thought it would
be possible in another way. I will try it like this. But wouldn't it be
possible to set a self defined annotation to the class "Date" or "File"
which contains the actual field value and then write the get method in
the superclass so, that it accesses the annotation of the concrete
eclass based on the instance? So i would have
DialogElement.getType() -> this.getEClass().getMyAnnotationValue()
(this is really pseudo code)
It is really just thinking and discussing. Don't be to hard on me if
this is too complicated, impossible or anything else :-)
Daniel
Am 11.08.11 14:42, schrieb Hallvard Trætteberg:
> I don't think you can override the default value. What you could do is
> to model it as a derived feature and implement the corresponding get
> method in the subclass' implementation. That way the values may differ
> and you still access it as a "normal" attribute.
>
> hallvard
>
> On 11.08.11 14.36, Daniel Winkels wrote:
>> Am 11.08.11 14:18, schrieb Daniel Winkels:
>>> Hello Ed,
>>>
>>> i assumed that the question is somehow unclear. I uploaded an image
>>> with a small example of what i am intending to do.
>>> I just explain it:
>>>
>>> "DialogElement" is the abstract common base of "File" and "Date".
>>> There will be no instance of "DialogElement" but of its children. All
>>> I want to do is set the field "type" = "DateField" or "type" =
>>> "FileField" according to the Class of the instance. There will be no
>>> need to change the value again, so it can be set statically or on
>>> initialization time. I just do not know how to assign static or
>>> default values in a subclass to a field that is modeled in the
>>> superclass.
>>>
>>> I hope it is getting clearer :)
>>
>> I just saw that my image is wrong. The superclass of Date should be
>> DialogElement.
>
|
|
|
Re: specialization [message #714774 is a reply to message #714769] |
Thu, 11 August 2011 13:11 |
Daniel Winkels Messages: 19 Registered: October 2010 |
Junior Member |
|
|
So,
this is my solution in DialogElement:
public String getType() {
return this.eClass().getName() + "Field";
}
I just was hoping for an annotation that gives me the opportunity to set
the value of each subclass individually. So if anybody knows a way, i am
still interested, but so far this solves my problem for the near future
(at least i hope)
So, thank you!
Daniel
Am 11.08.11 14:42, schrieb Hallvard Trætteberg:
> I don't think you can override the default value. What you could do is
> to model it as a derived feature and implement the corresponding get
> method in the subclass' implementation. That way the values may differ
> and you still access it as a "normal" attribute.
>
> hallvard
>
> On 11.08.11 14.36, Daniel Winkels wrote:
>> Am 11.08.11 14:18, schrieb Daniel Winkels:
>>> Hello Ed,
>>>
>>> i assumed that the question is somehow unclear. I uploaded an image
>>> with a small example of what i am intending to do.
>>> I just explain it:
>>>
>>> "DialogElement" is the abstract common base of "File" and "Date".
>>> There will be no instance of "DialogElement" but of its children. All
>>> I want to do is set the field "type" = "DateField" or "type" =
>>> "FileField" according to the Class of the instance. There will be no
>>> need to change the value again, so it can be set statically or on
>>> initialization time. I just do not know how to assign static or
>>> default values in a subclass to a field that is modeled in the
>>> superclass.
>>>
>>> I hope it is getting clearer :)
>>
>> I just saw that my image is wrong. The superclass of Date should be
>> DialogElement.
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03517 seconds