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

pack-priv final Class FieldMaskTree

extends Object
Class Inheritance
Imports
com.google.errorprone.annotations.CanIgnoreReturnValue, com.google.protobuf.Descriptors.Descriptor, .Descriptors.FieldDescriptor, .FieldMask, .Message, java.util.ArrayList, .List, .Map.Entry, .SortedMap, .TreeMap, java.util.logging.Logger

A tree representation of a FieldMask. Each leaf node in this tree represent a field path in the FieldMask.

For example, FieldMask "foo.bar,foo.baz,bar.baz" as a tree will be:

  [root] -+- foo -+- bar
          |       |
          |       +- baz
          |
          +- bar --- baz

By representing FieldMasks with this tree structure we can easily convert a FieldMask to a canonical form, merge two FieldMasks, calculate the intersection to two FieldMasks and traverse all fields specified by the FieldMask in a message tree.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final Logger
private final FieldMaskTree.Node

Constructor Summary

AccessConstructor and Description
pack-priv
FieldMaskTree()

Creates an empty FieldMaskTree.

pack-priv
FieldMaskTree(FieldMask mask)

Creates a FieldMaskTree for a given FieldMask.

Method Summary

Modifier and TypeMethod and Description
pack-priv FieldMaskTree
addFieldPath(String path)

Adds a field path to the tree.

private void
getFieldPaths(FieldMaskTree.Node node, String path, List<String> paths)

Gathers all field paths in a sub-tree.

pack-priv void
intersectFieldPath(String path, FieldMaskTree output)

Adds the intersection of this tree with the given path to output.

pack-priv void
merge(Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges all fields specified by this FieldMaskTree from source to destination.

private void
merge(FieldMaskTree.Node node, String path, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges all fields specified by a sub-tree from source to destination.

pack-priv FieldMaskTree
mergeFromFieldMask(FieldMask mask)

Merges all field paths in a FieldMask into this tree.

pack-priv FieldMask
toFieldMask()

Converts this tree to a FieldMask.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

FIELD_PATH_SEPARATOR_REGEXback to summary
private static final String FIELD_PATH_SEPARATOR_REGEX
loggerback to summary
private static final Logger logger
rootback to summary
private final FieldMaskTree.Node root

Constructor Detail

FieldMaskTreeback to summary
pack-priv FieldMaskTree()

Creates an empty FieldMaskTree.

FieldMaskTreeback to summary
pack-priv FieldMaskTree(FieldMask mask)

Creates a FieldMaskTree for a given FieldMask.

Method Detail

addFieldPathback to summary
pack-priv FieldMaskTree addFieldPath(String path)

Adds a field path to the tree. In a FieldMask, every field path matches the specified field as well as all its sub-fields. For example, a field path "foo.bar" matches field "foo.bar" and also "foo.bar.baz", etc. When adding a field path to the tree, redundant sub-paths will be removed. That is, after adding "foo.bar" to the tree, "foo.bar.baz" will be removed if it exists, which will turn the tree node for "foo.bar" to a leaf node. Likewise, if the field path to add is a sub-path of an existing leaf node, nothing will be changed in the tree.

Annotations
@CanIgnoreReturnValue
getFieldPathsback to summary
private void getFieldPaths(FieldMaskTree.Node node, String path, List<String> paths)

Gathers all field paths in a sub-tree.

intersectFieldPathback to summary
pack-priv void intersectFieldPath(String path, FieldMaskTree output)

Adds the intersection of this tree with the given path to output.

mergeback to summary
pack-priv void merge(Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges all fields specified by this FieldMaskTree from source to destination.

mergeback to summary
private void merge(FieldMaskTree.Node node, String path, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)

Merges all fields specified by a sub-tree from source to destination.

mergeFromFieldMaskback to summary
pack-priv FieldMaskTree mergeFromFieldMask(FieldMask mask)

Merges all field paths in a FieldMask into this tree.

Annotations
@CanIgnoreReturnValue
toFieldMaskback to summary
pack-priv FieldMask toFieldMask()

Converts this tree to a FieldMask.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
com.google.protobuf.util back to summary

private final Class FieldMaskTree.Node

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final SortedMap<String, FieldMaskTree.Node>

Constructor Summary

AccessConstructor and Description
private
Node()

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
pack-priv final SortedMap<String, FieldMaskTree.Node> children

Constructor Detail

Nodeback to summary
private Node()