I'm trying to convert an old global class to be a virtual class so I can have some variations on its implementation. There is some existing behavior on the property Getters that I'd like to preserve in one of my new concrete subclasses.
The parent looks something like this:
global virtual class TestParent {
global String myName {get;set;}
global virtual void sayHi() { }
}
And the subclass looks like this.
global class TestChild extends TestParent {
global String getMyName() {
return myName + ' Smith';
}
global override void sayHi() {
System.debug('Hello, ' + myName );
}
}
What I'd like to do is be able to override the {get;} defined on my parent class in the subclass to perform some logic against the accessed attribute.
My thinking above was that global String myName {get;set;}
would translate to a getMyName()
method, but the property can't override it that way. Because the parent call is released as global, I need to continue being able to access the Child class the same way I used to access the Parent class, so I can't change it's implementation unless it continues exposing the same outward API.
Any help appreciated.
System.debug(testParentInstance.myName);
and will now be able to callSystem.debug(testChildInstance.myName);
in a similar way. I can't just replace it with atestChildInstance.getMyName()
for example.