@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.datastore.v1.Key)) { return super.equals(obj); } com.google.datastore.v1.Key other = (com.google.datastore.v1.Key) obj; boolean result = true; result = result && (hasPartitionId() == other.hasPartitionId()); if (hasPartitionId()) { result = result && getPartitionId().equals(other.getPartitionId()); } result = result && getPathList().equals(other.getPathList()); 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 (hasPartitionId()) { hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; hash = (53 * hash) + getPartitionId().hashCode(); } if (getPathCount() > 0) { hash = (37 * hash) + PATH_FIELD_NUMBER; hash = (53 * hash) + getPathList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * A key value. * </pre> * * <code>.google.datastore.v1.Key key_value = 5;</code> */ public Builder mergeKeyValue(com.google.datastore.v1.Key value) { if (keyValueBuilder_ == null) { if (valueTypeCase_ == 5 && valueType_ != com.google.datastore.v1.Key.getDefaultInstance()) { valueType_ = com.google.datastore.v1.Key.newBuilder((com.google.datastore.v1.Key) valueType_) .mergeFrom(value) .buildPartial(); } else { valueType_ = value; } onChanged(); } else { if (valueTypeCase_ == 5) { keyValueBuilder_.mergeFrom(value); } keyValueBuilder_.setMessage(value); } valueTypeCase_ = 5; return this; } /**
Key.Builder key = Key.newBuilder(); PartitionId partitionId = null; for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { Key subKey = (Key) element; if (partitionId == null) { partitionId = subKey.getPartitionId(); } else if (!partitionId.equals(subKey.getPartitionId())) { throw new IllegalArgumentException("Partition IDs did not match, found: " + partitionId + " and " + subKey.getPartitionId()); key.addAllPath(((Key) element).getPathList());
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (hasPartitionId()) { hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; hash = (53 * hash) + getPartitionId().hashCode(); } if (getPathCount() > 0) { hash = (37 * hash) + PATH_FIELD_NUMBER; hash = (53 * hash) + getPathList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Override public int compare(Key thisKey, Key otherKey) { if (!thisKey.getPartitionId().equals(otherKey.getPartitionId())) { throw new IllegalArgumentException("Cannot compare keys with different partition ids."); } Iterator<PathElement> thisPath = thisKey.getPathList().iterator(); Iterator<PathElement> otherPath = otherKey.getPathList().iterator(); while (thisPath.hasNext()) { if (!otherPath.hasNext()) { return 1; } int result = comparePathElement(thisPath.next(), otherPath.next()); if (result != 0) { return result; } } return otherPath.hasNext() ? -1 : 0; } }
/** * Return element path that represents this key. * * @return a list of path elements that make up this key. */ public List<Element> getPath() { return ImmutableList.copyOf(key.getPathList().stream() .map(Element::new) .collect(Collectors.toList())); }
public Builder mergeFrom(com.google.datastore.v1.Key other) { if (other == com.google.datastore.v1.Key.getDefaultInstance()) return this; if (other.hasPartitionId()) { mergePartitionId(other.getPartitionId());
/** * * * <pre> * Entities are partitioned into subsets, currently identified by a project * ID and namespace ID. * Queries are scoped to a single partition. * </pre> * * <code>.google.datastore.v1.PartitionId partition_id = 1;</code> */ public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { return getPartitionId(); }
/** * Return whether this key is complete or not. * * A complete key is a key that includes a "kind" and ("id" or "name"). * * @return true if the key is complete. */ public boolean isComplete() { if (key.getPathCount() == 0) { return false; } return key.getPathList().stream().allMatch(e -> isId(e) || isName(e)); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasKey()) { hash = (37 * hash) + KEY_FIELD_NUMBER; hash = (53 * hash) + getKey().hashCode(); } hash = (37 * hash) + VERSION_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersion()); hash = (37 * hash) + CONFLICT_DETECTED_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getConflictDetected()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
com.google.datastore.v1.Value getPb(final String namespace) { final com.google.datastore.v1.Key key = value.getKeyValue(); if (key.getPathCount() > 0) { return com.google.datastore.v1.Value. newBuilder(value) .setKeyValue(getKey().getPb(namespace)).build(); } return value; }
Key.Builder key = Key.newBuilder(); PartitionId partitionId = null; for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { Key subKey = (Key) element; if (partitionId == null) { partitionId = subKey.getPartitionId(); } else if (!partitionId.equals(subKey.getPartitionId())) { throw new IllegalArgumentException("Partition IDs did not match, found: " + partitionId + " and " + subKey.getPartitionId()); key.addAllPath(((Key) element).getPathList());
if (operationCase_ == 7 && operation_ != com.google.datastore.v1.Key.getDefaultInstance()) { operation_ = com.google.datastore.v1.Key.newBuilder((com.google.datastore.v1.Key) operation_) .mergeFrom(value) .buildPartial();
@Override public int compare(Key thisKey, Key otherKey) { if (!thisKey.getPartitionId().equals(otherKey.getPartitionId())) { throw new IllegalArgumentException("Cannot compare keys with different partition ids."); } Iterator<PathElement> thisPath = thisKey.getPathList().iterator(); Iterator<PathElement> otherPath = otherKey.getPathList().iterator(); while (thisPath.hasNext()) { if (!otherPath.hasNext()) { return 1; } int result = comparePathElement(thisPath.next(), otherPath.next()); if (result != 0) { return result; } } return otherPath.hasNext() ? -1 : 0; } }
/** * Return element kind of key, or null if not set. * * This is a shortcut for {@code Key.getPath().get(Key.getPath().size() - 1).getKind()} * * @return the element kind. */ public String getKind() { final com.google.datastore.v1.Key.PathElement element = Iterables.getLast(key.getPathList(), null); if (element == null) { return null; } return element.getKind(); }
public Builder mergeFrom(com.google.datastore.v1.Key other) { if (other == com.google.datastore.v1.Key.getDefaultInstance()) return this; if (other.hasPartitionId()) { mergePartitionId(other.getPartitionId());
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (partitionId_ != null) { output.writeMessage(1, getPartitionId()); } for (int i = 0; i < path_.size(); i++) { output.writeMessage(2, path_.get(i)); } unknownFields.writeTo(output); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasKey()) { hash = (37 * hash) + KEY_FIELD_NUMBER; hash = (53 * hash) + getKey().hashCode(); } if (!internalGetProperties().getMap().isEmpty()) { hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; hash = (53 * hash) + internalGetProperties().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }