I'm looking for a quick/elegant way to wrap a super class and many different sub-classes that all extend the same super class.
Say i have a class MySuper and i have already wrapped that class using AbsObjectWrapper:
Now i have 6 or 7 other classes that extend MySuper class, each of these 6 or 7 other classes add various methods and properties to MySuper.
MySuper already has many methods and properties.
So a 'brute force' solution is to wrap each sub-class of MySuper and duplicate the code that wraps all methods and properties of MySuper:
Do-able but there must be a better and more elegant solution?
I was reading this recent thread: http://www.b4x.com/forum/bugs-wishl...d-feature-toggle-button-click.html#post152489.
Is there a solution that uses generics and parameterized classes?
(These are java concepts i have yet to deal with in any depth).
Could i wrap the super class and then re-use that wrapped class when wrapping the sub-classes and avoid lots of duplicate code?
If the java library and these classes i am wrapping gets updated then maintenance of the b4a library will be a pain in the a#se unless i can find the solution i am looking for.
Thanks.
Martin.
Say i have a class MySuper and i have already wrapped that class using AbsObjectWrapper:
B4X:
public class MySuperWrapper extends AbsObjectWrapper<MySuper> {
public void Initialize(){
setObject(new MySuper());
}
public void DoSomething(){
getObject().doSomething();
}
}
Now i have 6 or 7 other classes that extend MySuper class, each of these 6 or 7 other classes add various methods and properties to MySuper.
MySuper already has many methods and properties.
So a 'brute force' solution is to wrap each sub-class of MySuper and duplicate the code that wraps all methods and properties of MySuper:
B4X:
public class SubClass1Wrapper extends AbsObjectWrapper<SubClass1> {
public void Initialize(){
setObject(new SubClass1());
}
public void DoSomething(){
getObject().doSomething();
}
public void NewMethod(){
getObject().newMethod();
}
}
B4X:
public class SubClass2Wrapper extends AbsObjectWrapper<SubClass2> {
public void Initialize(){
setObject(new SubClass2());
}
public void DoSomething(){
getObject().doSomething();
}
public void AnotherNewMethod(){
getObject().anotherNewMethod();
}
}
Do-able but there must be a better and more elegant solution?
I was reading this recent thread: http://www.b4x.com/forum/bugs-wishl...d-feature-toggle-button-click.html#post152489.
Is there a solution that uses generics and parameterized classes?
(These are java concepts i have yet to deal with in any depth).
Could i wrap the super class and then re-use that wrapped class when wrapping the sub-classes and avoid lots of duplicate code?
If the java library and these classes i am wrapping gets updated then maintenance of the b4a library will be a pain in the a#se unless i can find the solution i am looking for.
Thanks.
Martin.