Sorry, I should have been a bit clearer.
You've defined a new interface called GeneratedMessageParser, and when someone instantiates a generic class which needs to parse things, they need to pass in an instance of your interface to do the parsing.
I'm saying that they can just pass in the message type's default instance instead. The default instance is explicitly intended to serve the purpose that your GeneratedMessageParser serves (among other things).
class Frobber<M extends Message> {
M prototype;
public Frobber(M prototype) {
this.prototype = prototype;
}
public M parse(ByteString data) {
return prototype.newBuilderForType().mergeFrom(data).build();
}
}
// some code that uses this
Frobber<MyType> frobber = new Frobber<MyType>(MyType.getDefaultInstance());
MyType result = frobber.parse(someData);