blob: 6ddceec0288940d84dcee8cd6bd931a52d1be3f9 [file] [log] [blame]
import java.util.Map;
public class NullsAndGenerics<E> {
private boolean enableProtoAnnotations;
@SuppressWarnings("unchecked")
private <T, O extends Message, E extends ProtoElement> T getProtoExtension(
E element, GeneratedExtension<O, T> extension) {
// Use this method as the chokepoint for all field annotations processing, so we can
// toggle on/off annotations processing in one place.
if (!enableProtoAnnotations) {
return null;
}
return (T) element.getOptionFields().get(extension.getDescriptor());
}
// stubs of relevant classes
private class Message {}
private class ProtoElement {
public Map<FieldDescriptor, Object> getOptionFields() {
return null;
}
}
private class FieldDescriptor {}
private class GeneratedExtension<O, T> {
public FieldDescriptor getDescriptor() {
return null;
}
}
}