Class SchemaUtil

java.lang.Object
com.google.protobuf.SchemaUtil

@ExperimentalApi @CheckReturnValue final class SchemaUtil extends Object
Helper methods used by schemas.
  • Field Details

    • GENERATED_MESSAGE_CLASS

      private static final Class<?> GENERATED_MESSAGE_CLASS
    • UNKNOWN_FIELD_SET_FULL_SCHEMA

      private static final UnknownFieldSchema<?,?> UNKNOWN_FIELD_SET_FULL_SCHEMA
    • UNKNOWN_FIELD_SET_LITE_SCHEMA

      private static final UnknownFieldSchema<?,?> UNKNOWN_FIELD_SET_LITE_SCHEMA
    • DEFAULT_LOOK_UP_START_NUMBER

      private static final int DEFAULT_LOOK_UP_START_NUMBER
      See Also:
  • Constructor Details

    • SchemaUtil

      private SchemaUtil()
  • Method Details

    • requireGeneratedMessage

      public static void requireGeneratedMessage(Class<?> messageType)
      Requires that the given message extend GeneratedMessage or GeneratedMessageLite.
    • writeDouble

      public static void writeDouble(int fieldNumber, double value, Writer writer) throws IOException
      Throws:
      IOException
    • writeFloat

      public static void writeFloat(int fieldNumber, float value, Writer writer) throws IOException
      Throws:
      IOException
    • writeInt64

      public static void writeInt64(int fieldNumber, long value, Writer writer) throws IOException
      Throws:
      IOException
    • writeUInt64

      public static void writeUInt64(int fieldNumber, long value, Writer writer) throws IOException
      Throws:
      IOException
    • writeSInt64

      public static void writeSInt64(int fieldNumber, long value, Writer writer) throws IOException
      Throws:
      IOException
    • writeFixed64

      public static void writeFixed64(int fieldNumber, long value, Writer writer) throws IOException
      Throws:
      IOException
    • writeSFixed64

      public static void writeSFixed64(int fieldNumber, long value, Writer writer) throws IOException
      Throws:
      IOException
    • writeInt32

      public static void writeInt32(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeUInt32

      public static void writeUInt32(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeSInt32

      public static void writeSInt32(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeFixed32

      public static void writeFixed32(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeSFixed32

      public static void writeSFixed32(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeEnum

      public static void writeEnum(int fieldNumber, int value, Writer writer) throws IOException
      Throws:
      IOException
    • writeBool

      public static void writeBool(int fieldNumber, boolean value, Writer writer) throws IOException
      Throws:
      IOException
    • writeString

      public static void writeString(int fieldNumber, Object value, Writer writer) throws IOException
      Throws:
      IOException
    • writeStringInternal

      private static void writeStringInternal(int fieldNumber, String value, Writer writer) throws IOException
      Throws:
      IOException
    • writeBytes

      public static void writeBytes(int fieldNumber, ByteString value, Writer writer) throws IOException
      Throws:
      IOException
    • writeMessage

      public static void writeMessage(int fieldNumber, Object value, Writer writer) throws IOException
      Throws:
      IOException
    • writeDoubleList

      public static void writeDoubleList(int fieldNumber, List<Double> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeFloatList

      public static void writeFloatList(int fieldNumber, List<Float> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeInt64List

      public static void writeInt64List(int fieldNumber, List<Long> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeUInt64List

      public static void writeUInt64List(int fieldNumber, List<Long> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeSInt64List

      public static void writeSInt64List(int fieldNumber, List<Long> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeFixed64List

      public static void writeFixed64List(int fieldNumber, List<Long> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeSFixed64List

      public static void writeSFixed64List(int fieldNumber, List<Long> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeInt32List

      public static void writeInt32List(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeUInt32List

      public static void writeUInt32List(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeSInt32List

      public static void writeSInt32List(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeFixed32List

      public static void writeFixed32List(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeSFixed32List

      public static void writeSFixed32List(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeEnumList

      public static void writeEnumList(int fieldNumber, List<Integer> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeBoolList

      public static void writeBoolList(int fieldNumber, List<Boolean> value, Writer writer, boolean packed) throws IOException
      Throws:
      IOException
    • writeStringList

      public static void writeStringList(int fieldNumber, List<String> value, Writer writer) throws IOException
      Throws:
      IOException
    • writeBytesList

      public static void writeBytesList(int fieldNumber, List<ByteString> value, Writer writer) throws IOException
      Throws:
      IOException
    • writeMessageList

      public static void writeMessageList(int fieldNumber, List<?> value, Writer writer) throws IOException
      Throws:
      IOException
    • writeMessageList

      public static void writeMessageList(int fieldNumber, List<?> value, Writer writer, Schema<?> schema) throws IOException
      Throws:
      IOException
    • writeLazyFieldList

      public static void writeLazyFieldList(int fieldNumber, List<?> value, Writer writer) throws IOException
      Throws:
      IOException
    • writeGroupList

      public static void writeGroupList(int fieldNumber, List<?> value, Writer writer) throws IOException
      Throws:
      IOException
    • writeGroupList

      public static void writeGroupList(int fieldNumber, List<?> value, Writer writer, Schema<?> schema) throws IOException
      Throws:
      IOException
    • computeSizeInt64ListNoTag

      static int computeSizeInt64ListNoTag(List<Long> list)
    • computeSizeInt64List

      static int computeSizeInt64List(int fieldNumber, List<Long> list, boolean packed)
    • computeSizeUInt64ListNoTag

      static int computeSizeUInt64ListNoTag(List<Long> list)
    • computeSizeUInt64List

      static int computeSizeUInt64List(int fieldNumber, List<Long> list, boolean packed)
    • computeSizeSInt64ListNoTag

      static int computeSizeSInt64ListNoTag(List<Long> list)
    • computeSizeSInt64List

      static int computeSizeSInt64List(int fieldNumber, List<Long> list, boolean packed)
    • computeSizeEnumListNoTag

      static int computeSizeEnumListNoTag(List<Integer> list)
    • computeSizeEnumList

      static int computeSizeEnumList(int fieldNumber, List<Integer> list, boolean packed)
    • computeSizeInt32ListNoTag

      static int computeSizeInt32ListNoTag(List<Integer> list)
    • computeSizeInt32List

      static int computeSizeInt32List(int fieldNumber, List<Integer> list, boolean packed)
    • computeSizeUInt32ListNoTag

      static int computeSizeUInt32ListNoTag(List<Integer> list)
    • computeSizeUInt32List

      static int computeSizeUInt32List(int fieldNumber, List<Integer> list, boolean packed)
    • computeSizeSInt32ListNoTag

      static int computeSizeSInt32ListNoTag(List<Integer> list)
    • computeSizeSInt32List

      static int computeSizeSInt32List(int fieldNumber, List<Integer> list, boolean packed)
    • computeSizeFixed32ListNoTag

      static int computeSizeFixed32ListNoTag(List<?> list)
    • computeSizeFixed32List

      static int computeSizeFixed32List(int fieldNumber, List<?> list, boolean packed)
    • computeSizeFixed64ListNoTag

      static int computeSizeFixed64ListNoTag(List<?> list)
    • computeSizeFixed64List

      static int computeSizeFixed64List(int fieldNumber, List<?> list, boolean packed)
    • computeSizeBoolListNoTag

      static int computeSizeBoolListNoTag(List<?> list)
    • computeSizeBoolList

      static int computeSizeBoolList(int fieldNumber, List<?> list, boolean packed)
    • computeSizeStringList

      static int computeSizeStringList(int fieldNumber, List<?> list)
    • computeSizeMessage

      static int computeSizeMessage(int fieldNumber, Object value, Schema<?> schema)
    • computeSizeMessageList

      static int computeSizeMessageList(int fieldNumber, List<?> list)
    • computeSizeMessageList

      static int computeSizeMessageList(int fieldNumber, List<?> list, Schema<?> schema)
    • computeSizeByteStringList

      static int computeSizeByteStringList(int fieldNumber, List<ByteString> list)
    • computeSizeGroupList

      static int computeSizeGroupList(int fieldNumber, List<MessageLite> list)
    • computeSizeGroupList

      static int computeSizeGroupList(int fieldNumber, List<MessageLite> list, Schema<?> schema)
    • shouldUseTableSwitch

      public static boolean shouldUseTableSwitch(FieldInfo[] fields)
      Determines whether to issue tableswitch or lookupswitch for the mergeFrom method.
      See Also:
    • shouldUseTableSwitch

      public static boolean shouldUseTableSwitch(int lo, int hi, int numFields)
      Determines whether to issue tableswitch or lookupswitch for the mergeFrom method. This is based on the logic in the JDK.
      Parameters:
      lo - the lowest fieldNumber contained within the message.
      hi - the highest fieldNumber contained within the message.
      numFields - the total number of fields in the message.
      Returns:
      true if tableswitch should be used, rather than lookupswitch.
    • unknownFieldSetFullSchema

      public static UnknownFieldSchema<?,?> unknownFieldSetFullSchema()
    • unknownFieldSetLiteSchema

      public static UnknownFieldSchema<?,?> unknownFieldSetLiteSchema()
    • getUnknownFieldSetSchema

      private static UnknownFieldSchema<?,?> getUnknownFieldSetSchema()
    • getGeneratedMessageClass

      private static Class<?> getGeneratedMessageClass()
    • getUnknownFieldSetSchemaClass

      private static Class<?> getUnknownFieldSetSchemaClass()
    • getMapDefaultEntry

      static Object getMapDefaultEntry(Class<?> clazz, String name)
    • toCamelCase

      static String toCamelCase(String name, boolean capNext)
    • safeEquals

      static boolean safeEquals(Object a, Object b)
      Returns true if both are null or both are Object.equals(java.lang.Object).
    • mergeMap

      static <T> void mergeMap(MapFieldSchema mapFieldSchema, T message, T o, long offset)
    • mergeExtensions

      static <T, FT extends FieldSet.FieldDescriptorLite<FT>> void mergeExtensions(ExtensionSchema<FT> schema, T message, T other)
    • mergeUnknownFields

      static <T, UT, UB> void mergeUnknownFields(UnknownFieldSchema<UT,UB> schema, T message, T other)
    • filterUnknownEnumList

      static <UT, UB> UB filterUnknownEnumList(Object containerMessage, int number, List<Integer> enumList, Internal.EnumLiteMap<?> enumMap, UB unknownFields, UnknownFieldSchema<UT,UB> unknownFieldSchema)
      Filters unrecognized enum values in a list.
    • filterUnknownEnumList

      static <UT, UB> UB filterUnknownEnumList(Object containerMessage, int number, List<Integer> enumList, Internal.EnumVerifier enumVerifier, UB unknownFields, UnknownFieldSchema<UT,UB> unknownFieldSchema)
      Filters unrecognized enum values in a list.
    • storeUnknownEnum

      static <UT, UB> UB storeUnknownEnum(Object containerMessage, int number, int enumValue, UB unknownFields, UnknownFieldSchema<UT,UB> unknownFieldSchema)
      Stores an unrecognized enum value as an unknown value.