Top Description Inners Fields Constructors Methods
com.google.protobuf.util

public Class FieldMaskUtil

extends Object
Class Inheritance
Static Imports
com.google.common.base.Preconditions.checkArgument

Utility helper functions to work with com.google.protobuf.FieldMask.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FieldMaskUtil.MergeOptions

Options to customize merging behavior.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FieldMask
fromFieldNumbers(Class<? extends Message> type, int... fieldNumbers)

Constructs a FieldMask from the passed field numbers.

public static FieldMask
fromFieldNumbers(Class<? extends Message> type, Iterable<Integer> fieldNumbers)

Constructs a FieldMask from the passed field numbers.

public static FieldMask
fromJsonString(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.

public static FieldMask
fromString(String value)

Parses from a string to a FieldMask.

public static FieldMask
fromString(Class<? extends Message> type, String value)

Parses from a string to a FieldMask and validates all field paths.

public static FieldMask
fromStringList(Class<? extends Message> type, Iterable<String> paths)

Constructs a FieldMask for a list of field paths in a certain type.

public static FieldMask
intersection(FieldMask mask1, FieldMask mask2)

Calculates the intersection of two FieldMasks.

public static boolean
isValid(Class<? extends Message> type, FieldMask fieldMask)

Checks whether paths in a given fields mask are valid.

public static boolean
isValid(Descriptors.Descriptor descriptor, FieldMask fieldMask)

Checks whether paths in a given fields mask are valid.

public static boolean
isValid(Class<? extends Message> type, String path)

Checks whether a given field path is valid.

public static boolean
isValid(Descriptors.Descriptor descriptor, String path)

Checks whether paths in a given fields mask are valid.

public static void
merge(FieldMask mask, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges fields specified by a FieldMask from one message to another with the specified merge options.

public static void
merge(FieldMask mask, Message source, Message.Builder destination)

Merges fields specified by a FieldMask from one message to another.

public static FieldMask
normalize(FieldMask mask)

Converts a FieldMask to its canonical form.

public static String
toJsonString(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.

public static String
toString(FieldMask fieldMask)

Converts a FieldMask to a string.

public static FieldMask
union(FieldMask firstMask, FieldMask secondMask, FieldMask... otherMasks)

Creates a union of two or more FieldMasks.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FIELD_PATH_SEPARATORback to summary
private static final String FIELD_PATH_SEPARATOR
FIELD_PATH_SEPARATOR_REGEXback to summary
private static final String FIELD_PATH_SEPARATOR_REGEX
FIELD_SEPARATOR_REGEXback to summary
private static final String FIELD_SEPARATOR_REGEX

Constructor Detail

FieldMaskUtilback to summary
private FieldMaskUtil()

Method Detail

fromFieldNumbersback to summary
public static FieldMask fromFieldNumbers(Class<? extends Message> type, int... fieldNumbers)

Constructs a FieldMask from the passed field numbers.

Exceptions
IllegalArgumentException:
if any of the fields are invalid for the message.
fromFieldNumbersback to summary
public static FieldMask fromFieldNumbers(Class<? extends Message> type, Iterable<Integer> fieldNumbers)

Constructs a FieldMask from the passed field numbers.

Exceptions
IllegalArgumentException:
if any of the fields are invalid for the message.
fromJsonStringback to summary
public static FieldMask fromJsonString(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.

fromStringback to summary
public static FieldMask fromString(String value)

Parses from a string to a FieldMask.

fromStringback to summary
public static FieldMask fromString(Class<? extends Message> type, String value)

Parses from a string to a FieldMask and validates all field paths.

Exceptions
IllegalArgumentException:
if any of the field path is invalid.
fromStringListback to summary
public static FieldMask fromStringList(Class<? extends Message> type, Iterable<String> paths)

Constructs a FieldMask for a list of field paths in a certain type.

Exceptions
IllegalArgumentException:
if any of the field path is not valid.
intersectionback to summary
public static FieldMask intersection(FieldMask mask1, FieldMask mask2)

Calculates the intersection of two FieldMasks.

isValidback to summary
public static boolean isValid(Class<? extends Message> type, FieldMask fieldMask)

Checks whether paths in a given fields mask are valid.

isValidback to summary
public static boolean isValid(Descriptors.Descriptor descriptor, FieldMask fieldMask)

Checks whether paths in a given fields mask are valid.

isValidback to summary
public static boolean isValid(Class<? extends Message> type, String path)

Checks whether a given field path is valid.

isValidback to summary
public static boolean isValid(Descriptors.Descriptor descriptor, String path)

Checks whether paths in a given fields mask are valid.

mergeback to summary
public static void merge(FieldMask mask, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges fields specified by a FieldMask from one message to another with the specified merge options.

mergeback to summary
public static void merge(FieldMask mask, Message source, Message.Builder destination)

Merges fields specified by a FieldMask from one message to another.

normalizeback to summary
public static FieldMask normalize(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.

toJsonStringback to summary
public static String toJsonString(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.

toStringback to summary
public static String toString(FieldMask fieldMask)

Converts a FieldMask to a string.

unionback to summary
public static FieldMask union(FieldMask firstMask, FieldMask secondMask, FieldMask... otherMasks)

Creates a union of two or more FieldMasks.

com.google.protobuf.util back to summary

public final Class FieldMaskUtil.MergeOptions

extends Object
Class Inheritance

Options to customize merging behavior.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
replaceMessageFields()

Whether to replace message fields (i.e., discard existing content in destination message fields).

public boolean
replacePrimitiveFields()

Whether to replace primitive (non-repeated and non-message) fields in destination message fields with the source primitive fields (i.e., clear destination field if source field is not set).

public boolean
replaceRepeatedFields()

Whether to replace repeated fields (i.e., discard existing content in destination repeated fields).

public FieldMaskUtil.MergeOptions
setReplaceMessageFields(boolean value)

Specify whether to replace message fields.

public FieldMaskUtil.MergeOptions
setReplacePrimitiveFields(boolean value)

Specify whether to replace primitive (non-repeated and non-message) fields in destination message fields with the source primitive fields.

public FieldMaskUtil.MergeOptions
setReplaceRepeatedFields(boolean value)

Specify whether to replace repeated fields.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

replaceMessageFieldsback to summary
private boolean replaceMessageFields
replacePrimitiveFieldsback to summary
private boolean replacePrimitiveFields
replaceRepeatedFieldsback to summary
private boolean replaceRepeatedFields

Constructor Detail

MergeOptionsback to summary
public MergeOptions()

Method Detail

replaceMessageFieldsback to summary
public boolean replaceMessageFields()

Whether to replace message fields (i.e., discard existing content in destination message fields).

replacePrimitiveFieldsback to summary
public boolean replacePrimitiveFields()

Whether to replace primitive (non-repeated and non-message) fields in destination message fields with the source primitive fields (i.e., clear destination field if source field is not set).

replaceRepeatedFieldsback to summary
public boolean replaceRepeatedFields()

Whether to replace repeated fields (i.e., discard existing content in destination repeated fields).

setReplaceMessageFieldsback to summary
public FieldMaskUtil.MergeOptions setReplaceMessageFields(boolean value)

Specify whether to replace message fields. Defaults to false.

If true, discard existing content in destination message fields when merging.

If false, merge the source message field into the destination message field.

Annotations
@CanIgnoreReturnValue
setReplacePrimitiveFieldsback to summary
public FieldMaskUtil.MergeOptions setReplacePrimitiveFields(boolean value)

Specify whether to replace primitive (non-repeated and non-message) fields in destination message fields with the source primitive fields. Defaults to false.

If true, set the value of the destination primitive field to the source primitive field if the source field is set, but clear the destination field otherwise.

If false, always set the value of the destination primitive field to the source primitive field, and if the source field is unset, the default value of the source field is copied to the destination.

Annotations
@CanIgnoreReturnValue
setReplaceRepeatedFieldsback to summary
public FieldMaskUtil.MergeOptions setReplaceRepeatedFields(boolean value)

Specify whether to replace repeated fields. Defaults to false.

If true, discard existing content in destination repeated fields) when merging.

If false, append elements from source repeated field to the destination repeated field.

Annotations
@CanIgnoreReturnValue