@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.protobuf.FieldMask)) { return super.equals(obj); } com.google.protobuf.FieldMask other = (com.google.protobuf.FieldMask) obj; boolean result = true; result = result && getPathsList() .equals(other.getPathsList()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getPathsCount() > 0) { hash = (37 * hash) + PATHS_FIELD_NUMBER; hash = (53 * hash) + getPathsList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; { int dataSize = 0; for (int i = 0; i < paths_.size(); i++) { dataSize += computeStringSizeNoTag(paths_.getRaw(i)); } size += dataSize; size += 1 * getPathsList().size(); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public PartialUpdateInstanceRequest toProto(String projectId) { // Empty field mask implies full resource replacement, which would clear all fields in an empty // update request. Preconditions.checkState( !builder.getUpdateMask().getPathsList().isEmpty(), "Update request is empty"); builder.getInstanceBuilder().setName(NameUtil.formatInstanceName(projectId, instanceId)); return builder.build(); } }
/** * <pre> * The set of field mask paths. * </pre> * * <code>repeated string paths = 1;</code> */ public java.util.List<String> getPathsList() { return java.util.Collections.unmodifiableList( instance.getPathsList()); } /**
/** * Checks whether paths in a given fields mask are valid. */ public static boolean isValid(Descriptor descriptor, FieldMask fieldMask) { for (String path : fieldMask.getPathsList()) { if (!isValid(descriptor, path)) { return false; } } return true; }
/** * Merges all field paths in a FieldMask into this tree. */ FieldMaskTree mergeFromFieldMask(FieldMask mask) { for (String path : mask.getPathsList()) { addFieldPath(path); } return this; }
/** * 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 toJsonString(FieldMask fieldMask) { List<String> paths = new ArrayList<String>(fieldMask.getPathsCount()); for (String path : fieldMask.getPathsList()) { if (path.isEmpty()) { continue; } paths.add(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, path)); } return Joiner.on(FIELD_PATH_SEPARATOR).join(paths); }
/** * Converts a FieldMask to a string. */ public static String toString(FieldMask fieldMask) { // TODO(xiaofeng): Consider using com.google.common.base.Joiner here instead. StringBuilder result = new StringBuilder(); boolean first = true; for (String value : fieldMask.getPathsList()) { if (value.isEmpty()) { // Ignore empty paths. continue; } if (first) { first = false; } else { result.append(FIELD_PATH_SEPARATOR); } result.append(value); } return result.toString(); }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; { int dataSize = 0; for (int i = 0; i < paths_.size(); i++) { dataSize += com.google.protobuf.CodedOutputStream .computeStringSizeNoTag(paths_.get(i)); } size += dataSize; size += 1 * getPathsList().size(); } memoizedSerializedSize = size; return size; }
/** * Calculates the intersection of two FieldMasks. */ public static FieldMask intersection(FieldMask mask1, FieldMask mask2) { FieldMaskTree tree = new FieldMaskTree(mask1); FieldMaskTree result = new FieldMaskTree(); for (String path : mask2.getPathsList()) { tree.intersectFieldPath(path, result); } return result.toFieldMask(); }
/** * Creates the request protobuf. This method is considered an internal implementation detail and * not meant to be used by applications. */ @InternalApi public PartialUpdateInstanceRequest toProto(String projectId) { // Empty field mask implies full resource replacement, which would clear all fields in an empty // update request. Preconditions.checkState( !builder.getUpdateMask().getPathsList().isEmpty(), "Update request is empty"); builder.getInstanceBuilder().setName(NameUtil.formatInstanceName(projectId, instanceId)); return builder.build(); } }