/** * 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); }
/** * 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 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); }
/** * Creates a {@link Parser} with default configuration. */ public static Parser parser() { return new Parser(TypeRegistry.getEmptyTypeRegistry(), false, Parser.DEFAULT_RECURSION_LIMIT); }