use of com.squareup.wire.schema.internal.parser.OptionReader in project schema2proto by entur.
the class ModifyProto method addFieldOption.
public void addFieldOption(FieldOption fieldOption, Schema prunedSchema) throws InvalidProtobufException {
MessageType type = (MessageType) prunedSchema.getType(fieldOption.targetMessageType);
if (type == null) {
throw new InvalidProtobufException("Did not find existing type " + fieldOption.targetMessageType);
}
Field field = type.field(fieldOption.field);
if (field == null) {
throw new InvalidProtobufException("Did not find existing field " + fieldOption.field);
}
if (StringUtils.isEmpty(fieldOption.option)) {
throw new InvalidProtobufException("Missing option for field " + fieldOption.field);
}
OptionReader reader = new OptionReader(new SyntaxReader(fieldOption.option.toCharArray(), null));
reader.readOptions().forEach(option -> field.options().add(option));
}
Aggregations