Search in sources :

Example 16 with Options

use of com.squareup.wire.schema.Options in project schema2proto by entur.

the class SchemaParser method createWrapper.

private MessageType createWrapper(String typeName, MessageType messageType, String wrapperFieldName, String targetNamespace, XSParticle particle, String fieldDoc, Location location, XSComplexType parentType, String wrapperDoc) {
    // Add message type to file
    List<OptionElement> messageOptions = new ArrayList<>();
    Options options = new Options(Options.MESSAGE_OPTIONS, messageOptions);
    MessageType wrapperType = new MessageType(ProtoType.get(typeName), location, wrapperDoc, typeName, options);
    wrapperType.setWrapperMessageType(true);
    messageType.nestedTypes().add(wrapperType);
    Options fieldOptions = getFieldOptions(particle);
    String fieldPackagename = NamespaceHelper.xmlNamespaceToProtoFieldPackagename(targetNamespace, configuration.forceProtoPackage);
    Field field = new Field(fieldPackagename, location, Label.REPEATED, wrapperFieldName, fieldDoc, messageType.getNextFieldNum(), typeName, fieldOptions, false);
    addField(messageType, field);
    localTypes.add(new LocalType(particle, wrapperType, messageType, field, NamespaceHelper.xmlNamespaceToProtoPackage(targetNamespace, configuration.forceProtoPackage), parentType));
    return wrapperType;
}
Also used : Options(com.squareup.wire.schema.Options) Field(com.squareup.wire.schema.Field) OptionElement(com.squareup.wire.schema.internal.parser.OptionElement) ArrayList(java.util.ArrayList) MessageType(com.squareup.wire.schema.MessageType)

Aggregations

Options (com.squareup.wire.schema.Options)16 Location (com.squareup.wire.schema.Location)15 ArrayList (java.util.ArrayList)15 Field (com.squareup.wire.schema.Field)14 OptionElement (com.squareup.wire.schema.internal.parser.OptionElement)14 MessageType (com.squareup.wire.schema.MessageType)13 EnumConstant (com.squareup.wire.schema.EnumConstant)9 ProtoFile (com.squareup.wire.schema.ProtoFile)9 EnumType (com.squareup.wire.schema.EnumType)8 Type (com.squareup.wire.schema.Type)8 HashSet (java.util.HashSet)8 OneOf (com.squareup.wire.schema.OneOf)7 Set (java.util.Set)7 Schema (com.squareup.wire.schema.Schema)6 LinkedHashSet (java.util.LinkedHashSet)6 List (java.util.List)6 Objects (java.util.Objects)6 Optional (java.util.Optional)6 Collectors (java.util.stream.Collectors)6 ImmutableList (com.google.common.collect.ImmutableList)5