newbie question about Abstract methods
hey, I'm working on a web application that I was given and I'm a little confused about
some of the code in some of the classes. These are some methods in this abstract class. I don't understand
how this post method works if the method it's calling is declared abstract. Could someone please tell me how this works?
Code :
public final Representation post(Representation entity, Variant variant) throws ResourceException {
prePostAuthorization(entity);
if (!authorizeGet()) {
return doUnauthenticatedGet(variant);
} else {
return doAuthenticatedPost(entity, variant);
}
}
protected abstract boolean authorizeGet();
Thanks
Re: newbie question about Abstract methods
Well, if the class is abstract, then you can't instantiate it. So, is it possible this abstract class is extended somewhere where the authorizeGet() method is implemented?
Re: newbie question about Abstract methods
Abstract methods are implemented in concrete child classes, so in the code you posted a child class would implement authorizeGet, the calling parent abstract class doesn't care how its implemented, only that it is (allows many children to implement the behavior differently, but the calling procedure can stay the same). Similar to the Template Design Pattern, where the calling class only cares about a method being implemented, not how it is implemented