Abstract class with Inner class - Inheritance

Discussion in 'Java' started by sven.furrer@gmail.com, Oct 18, 2007.

  1. Guest

    Hi everybody

    I have an abstract outer class with an inner class.
    My inner class has a isValide() method which uses attributes form my
    outer class.

    Various sub-classes extend my outer class.
    An other package contains classes which in their turn extend all these
    subclasses. Let's call them SubSubClass.

    Confused? - Me too ;-)

    My SubSubClass contains a new attribute, which has to be validated. I
    kind of would have to overwrite my isValid() method in my inner
    class.

    Any idea how I could do this in an "easy" way?

    Thanks a lot!
    Sven

    An attempt to draw the "class diagram":
    ===========
    | abstract
    | OuterClass
    |
    | ------------------
    | ¦ InnerClass
    | ¦-----------------
    | ¦ isValide()
    | ------------------
    ===========
    ^
    ¦
    ¦
    ===========
    SubClass
    ===========
    ^
    ¦
    ¦ other package:
    ¦
    ===========
    | SubSubClass
    | int newAttr;
    | ------------------
    | ¦ InnerClass
    | ¦-----------------
    | ¦ isValide()
    | ------------------
    ===========
     
    , Oct 18, 2007
    #1
    1. Advertising

  2. <> wrote:
    > I have an abstract outer class with an inner class.
    > My inner class has a isValide() method which uses attributes form my
    > outer class.


    > Various sub-classes extend my outer class.
    > An other package contains classes which in their turn extend all these
    > subclasses. Let's call them SubSubClass.


    > My SubSubClass contains a new attribute, which has to be validated. I
    > kind of would have to overwrite my isValid() method in my inner
    > class.


    One way could be that you add some getter-Method into your abstract
    OuterClass, that normally returns something "valid", which is then
    overridden in MySubSubClass to return it's attribute.
    The inner class' isValid() then accesses the getter-method and thus
    sees the derived class' attribute's value :)

    If this extra attribute really doesn't fit into the abstract outerclass'
    design, it would instead need a "pluggable" Validator, and a way to
    re-plug a different Validator object, which then could be actually of
    type MySpecialValidator, which would then know about that extra attribute
    and call it's baseClass' isValid for the other attributes.
     
    Andreas Leitgeb, Oct 18, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias Kaeppler
    Replies:
    1
    Views:
    471
    R.F. Pels
    May 22, 2005
  2. Sameer
    Replies:
    4
    Views:
    635
    Roedy Green
    Aug 31, 2005
  3. Uzytkownik
    Replies:
    3
    Views:
    610
    Uzytkownik
    Apr 3, 2005
  4. Pyenos
    Replies:
    2
    Views:
    420
    Pyenos
    Dec 27, 2006
  5. Replies:
    4
    Views:
    866
    Rolf Magnus
    May 17, 2006
Loading...

Share This Page