final class FieldMaskTree
extends java.lang.Object
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.
Modifier and Type | Class and Description |
---|---|
private static class |
FieldMaskTree.Node |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
FIELD_PATH_SEPARATOR_REGEX |
private static java.util.logging.Logger |
logger |
private FieldMaskTree.Node |
root |
Constructor and Description |
---|
FieldMaskTree()
Creates an empty FieldMaskTree.
|
FieldMaskTree(FieldMask mask)
Creates a FieldMaskTree for a given FieldMask.
|
Modifier and Type | Method and Description |
---|---|
(package private) FieldMaskTree |
addFieldPath(java.lang.String path)
Adds a field path to the tree.
|
private void |
getFieldPaths(FieldMaskTree.Node node,
java.lang.String path,
java.util.List<java.lang.String> paths)
Gathers all field paths in a sub-tree.
|
(package private) void |
intersectFieldPath(java.lang.String path,
FieldMaskTree output)
Adds the intersection of this tree with the given
path to output . |
private void |
merge(FieldMaskTree.Node node,
java.lang.String path,
Message source,
Message.Builder destination,
FieldMaskUtil.MergeOptions options)
Merges all fields specified by a sub-tree from
source to destination . |
(package private) void |
merge(Message source,
Message.Builder destination,
FieldMaskUtil.MergeOptions options)
Merges all fields specified by this FieldMaskTree from
source to destination . |
(package private) FieldMaskTree |
mergeFromFieldMask(FieldMask mask)
Merges all field paths in a FieldMask into this tree.
|
(package private) FieldMask |
toFieldMask()
Converts this tree to a FieldMask.
|
java.lang.String |
toString() |
private static final java.util.logging.Logger logger
private static final java.lang.String FIELD_PATH_SEPARATOR_REGEX
private final FieldMaskTree.Node root
FieldMaskTree()
FieldMaskTree(FieldMask mask)
public java.lang.String toString()
toString
in class java.lang.Object
FieldMaskTree addFieldPath(java.lang.String path)
FieldMaskTree mergeFromFieldMask(FieldMask mask)
FieldMask toFieldMask()
private void getFieldPaths(FieldMaskTree.Node node, java.lang.String path, java.util.List<java.lang.String> paths)
void intersectFieldPath(java.lang.String path, FieldMaskTree output)
path
to output
.void merge(Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)
source
to destination
.private void merge(FieldMaskTree.Node node, java.lang.String path, Message source, Message.Builder destination, FieldMaskUtil.MergeOptions options)
source
to destination
.