Class FieldMaskUtil


  • public final class FieldMaskUtil
    extends java.lang.Object
    Utility helper functions to work with FieldMask.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FieldMaskUtil.MergeOptions
      Options to customize merging behavior.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.protobuf.FieldMask fromFieldNumbers​(java.lang.Class<? extends com.google.protobuf.Message> type, int... fieldNumbers)
      Constructs a FieldMask from the passed field numbers.
      static com.google.protobuf.FieldMask fromFieldNumbers​(java.lang.Class<? extends com.google.protobuf.Message> type, java.lang.Iterable<java.lang.Integer> fieldNumbers)
      Constructs a FieldMask from the passed field numbers.
      static com.google.protobuf.FieldMask fromJsonString​(java.lang.String value)
      Converts a field mask from a Proto3 JSON string, that is splitting the paths along commas and converting from camel case to snake case.
      static com.google.protobuf.FieldMask fromString​(java.lang.Class<? extends com.google.protobuf.Message> type, java.lang.String value)
      Parses from a string to a FieldMask and validates all field paths.
      static com.google.protobuf.FieldMask fromString​(java.lang.String value)
      Parses from a string to a FieldMask.
      static com.google.protobuf.FieldMask fromStringList​(com.google.protobuf.Descriptors.Descriptor descriptor, java.lang.Iterable<java.lang.String> paths)
      Constructs a FieldMask for a list of field paths in a certain type.
      static com.google.protobuf.FieldMask fromStringList​(java.lang.Class<? extends com.google.protobuf.Message> type, java.lang.Iterable<java.lang.String> paths)
      Constructs a FieldMask for a list of field paths in a certain type.
      static com.google.protobuf.FieldMask fromStringList​(java.lang.Iterable<java.lang.String> paths)
      Constructs a FieldMask for a list of field paths in a certain type.
      static com.google.protobuf.FieldMask intersection​(com.google.protobuf.FieldMask mask1, com.google.protobuf.FieldMask mask2)
      Calculates the intersection of two FieldMasks.
      static boolean isValid​(com.google.protobuf.Descriptors.Descriptor descriptor, com.google.protobuf.FieldMask fieldMask)
      Checks whether paths in a given fields mask are valid.
      static boolean isValid​(com.google.protobuf.Descriptors.Descriptor descriptor, java.lang.String path)
      Checks whether paths in a given fields mask are valid.
      static boolean isValid​(java.lang.Class<? extends com.google.protobuf.Message> type, com.google.protobuf.FieldMask fieldMask)
      Checks whether paths in a given fields mask are valid.
      static boolean isValid​(java.lang.Class<? extends com.google.protobuf.Message> type, java.lang.String path)
      Checks whether a given field path is valid.
      static void merge​(com.google.protobuf.FieldMask mask, com.google.protobuf.Message source, com.google.protobuf.Message.Builder destination)
      Merges fields specified by a FieldMask from one message to another.
      static void merge​(com.google.protobuf.FieldMask mask, com.google.protobuf.Message source, com.google.protobuf.Message.Builder destination, FieldMaskUtil.MergeOptions options)
      Merges fields specified by a FieldMask from one message to another with the specified merge options.
      static com.google.protobuf.FieldMask normalize​(com.google.protobuf.FieldMask mask)
      Converts a FieldMask to its canonical form.
      static com.google.protobuf.FieldMask subtract​(com.google.protobuf.FieldMask firstMask, com.google.protobuf.FieldMask secondMask, com.google.protobuf.FieldMask... otherMasks)
      Subtracts secondMask and otherMasks from firstMask.
      static java.lang.String toJsonString​(com.google.protobuf.FieldMask fieldMask)
      Converts a field mask to a Proto3 JSON string, that is converting from snake case to camel case and joining all paths into one string with commas.
      static java.lang.String toString​(com.google.protobuf.FieldMask fieldMask)
      Converts a FieldMask to a string.
      static com.google.protobuf.FieldMask union​(com.google.protobuf.FieldMask firstMask, com.google.protobuf.FieldMask secondMask, com.google.protobuf.FieldMask... otherMasks)
      Creates a union of two or more FieldMasks.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toString

        public static java.lang.String toString​(com.google.protobuf.FieldMask fieldMask)
        Converts a FieldMask to a string.
      • fromString

        public static com.google.protobuf.FieldMask fromString​(java.lang.String value)
        Parses from a string to a FieldMask.
      • fromString

        public static com.google.protobuf.FieldMask fromString​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                                               java.lang.String value)
        Parses from a string to a FieldMask and validates all field paths.
        Throws:
        java.lang.IllegalArgumentException - if any of the field path is invalid.
      • fromStringList

        public static com.google.protobuf.FieldMask fromStringList​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                                                   java.lang.Iterable<java.lang.String> paths)
        Constructs a FieldMask for a list of field paths in a certain type.
        Throws:
        java.lang.IllegalArgumentException - if any of the field path is not valid.
      • fromStringList

        public static com.google.protobuf.FieldMask fromStringList​(com.google.protobuf.Descriptors.Descriptor descriptor,
                                                                   java.lang.Iterable<java.lang.String> paths)
        Constructs a FieldMask for a list of field paths in a certain type.
        Throws:
        java.lang.IllegalArgumentException - if any of the field path is not valid.
      • fromStringList

        public static com.google.protobuf.FieldMask fromStringList​(java.lang.Iterable<java.lang.String> paths)
        Constructs a FieldMask for a list of field paths in a certain type. Does not validate the given paths.
      • fromFieldNumbers

        public static com.google.protobuf.FieldMask fromFieldNumbers​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                                                     int... fieldNumbers)
        Constructs a FieldMask from the passed field numbers.
        Throws:
        java.lang.IllegalArgumentException - if any of the fields are invalid for the message.
      • fromFieldNumbers

        public static com.google.protobuf.FieldMask fromFieldNumbers​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                                                     java.lang.Iterable<java.lang.Integer> fieldNumbers)
        Constructs a FieldMask from the passed field numbers.
        Throws:
        java.lang.IllegalArgumentException - if any of the fields are invalid for the message.
      • toJsonString

        public static java.lang.String toJsonString​(com.google.protobuf.FieldMask fieldMask)
        Converts a field mask to a Proto3 JSON string, that is converting from snake case to camel case and joining all paths into one string with commas.
      • fromJsonString

        public static com.google.protobuf.FieldMask fromJsonString​(java.lang.String value)
        Converts a field mask from a Proto3 JSON string, that is splitting the paths along commas and converting from camel case to snake case.
      • isValid

        public static boolean isValid​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                      com.google.protobuf.FieldMask fieldMask)
        Checks whether paths in a given fields mask are valid.
      • isValid

        public static boolean isValid​(com.google.protobuf.Descriptors.Descriptor descriptor,
                                      com.google.protobuf.FieldMask fieldMask)
        Checks whether paths in a given fields mask are valid.
      • isValid

        public static boolean isValid​(java.lang.Class<? extends com.google.protobuf.Message> type,
                                      java.lang.String path)
        Checks whether a given field path is valid.
      • isValid

        public static boolean isValid​(com.google.protobuf.Descriptors.Descriptor descriptor,
                                      java.lang.String path)
        Checks whether paths in a given fields mask are valid.
      • normalize

        public static com.google.protobuf.FieldMask normalize​(com.google.protobuf.FieldMask mask)
        Converts a FieldMask to its canonical form. In the canonical form of a FieldMask, all field paths are sorted alphabetically and redundant field paths are removed.
      • union

        public static com.google.protobuf.FieldMask union​(com.google.protobuf.FieldMask firstMask,
                                                          com.google.protobuf.FieldMask secondMask,
                                                          com.google.protobuf.FieldMask... otherMasks)
        Creates a union of two or more FieldMasks.
      • subtract

        public static com.google.protobuf.FieldMask subtract​(com.google.protobuf.FieldMask firstMask,
                                                             com.google.protobuf.FieldMask secondMask,
                                                             com.google.protobuf.FieldMask... otherMasks)
        Subtracts secondMask and otherMasks from firstMask.
      • intersection

        public static com.google.protobuf.FieldMask intersection​(com.google.protobuf.FieldMask mask1,
                                                                 com.google.protobuf.FieldMask mask2)
        Calculates the intersection of two FieldMasks.
      • merge

        public static void merge​(com.google.protobuf.FieldMask mask,
                                 com.google.protobuf.Message source,
                                 com.google.protobuf.Message.Builder destination,
                                 FieldMaskUtil.MergeOptions options)
        Merges fields specified by a FieldMask from one message to another with the specified merge options. The destination will remain unchanged if an empty FieldMask is provided.
      • merge

        public static void merge​(com.google.protobuf.FieldMask mask,
                                 com.google.protobuf.Message source,
                                 com.google.protobuf.Message.Builder destination)
        Merges fields specified by a FieldMask from one message to another.