TypeRegistry registry = TypeRegistry.newBuilder().add(serviceResolver.listMessageTypes()).build();
Descriptor contentType = registry.find(getTypeName(typeUrl)); if (contentType == null) { throw new InvalidProtocolBufferException("Cannot resolve type: " + typeUrl);
/** * Creates a new {@link Printer} using the given registry. The new Printer * clones all other configurations from the current {@link Printer}. * * @throws IllegalArgumentException if a registry is already set. */ public Printer usingTypeRegistry(TypeRegistry registry) { if (this.registry != TypeRegistry.getEmptyTypeRegistry()) { throw new IllegalArgumentException("Only one registry is allowed."); } return new Printer( registry, alwaysOutputDefaultValueFields, includingDefaultValueFields, preservingProtoFieldNames, omittingInsignificantWhitespace, printingEnumsAsInts); }
File outFileJsonServiceConfig = new File(options.get(JSON_OUT)); TypeRegistry registry = addPlatformExtensions(TypeRegistry.newBuilder()) .add(Service.getDescriptor()) .add(com.google.protobuf.BoolValue.getDescriptor())
Descriptor type = registry.find(typeName); if (type == null) { throw new InvalidProtocolBufferException("Cannot find type for url: " + typeUrl);
File outFileJsonServiceConfig = new File(options.get(JSON_OUT)); TypeRegistry registry = addPlatformExtensions(TypeRegistry.newBuilder()) .add(Service.getDescriptor()) .add(com.google.protobuf.BoolValue.getDescriptor())
public EntityJsonParser() { TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(Entity.getDescriptor()) .build(); jsonParser = JsonFormat.parser() .usingTypeRegistry(typeRegistry); }
public EntityJsonPrinter() { TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(Entity.getDescriptor()) .build(); jsonPrinter = JsonFormat.printer() .usingTypeRegistry(typeRegistry) .omittingInsignificantWhitespace(); }
/** * Builds a {@link TypeRegistry}. This method can only be called once for * one Builder. */ public TypeRegistry build() { TypeRegistry result = new TypeRegistry(types); // Make sure the built {@link TypeRegistry} is immutable. types = null; return result; }
/** * Creates a {@link Parser} with default configuration. */ public static Parser parser() { return new Parser(TypeRegistry.getEmptyTypeRegistry(), false, Parser.DEFAULT_RECURSION_LIMIT); }
/** * Creates a {@link Printer} with default configurations. */ public static Printer printer() { return new Printer( TypeRegistry.getEmptyTypeRegistry(), false, Collections.<FieldDescriptor>emptySet(), false, false, false); }
/** * Creates a new {@link Parser} using the given registry. The new Parser * clones all other configurations from this Parser. * * @throws IllegalArgumentException if a registry is already set. */ public Parser usingTypeRegistry(TypeRegistry registry) { if (this.registry != TypeRegistry.getEmptyTypeRegistry()) { throw new IllegalArgumentException("Only one registry is allowed."); } return new Parser(registry, ignoringUnknownFields, recursionLimit); }