com.spotify.asyncdatastoreclient.Update Maven / Gradle / Ivy
/*
* Copyright (c) 2011-2015 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.spotify.asyncdatastoreclient;
import com.google.datastore.v1.Mutation;
import java.util.List;
/**
* An update statement.
*
* Update a single entity based on a given {@code Key} and properties.
*/
public class Update extends KeyedStatement implements MutationStatement {
private boolean upsert;
protected Entity.Builder entity;
Update(final Key key) {
super(key);
this.entity = Entity.builder(key);
}
Update(final Entity entity) {
super(entity.getKey());
this.entity = Entity.builder(entity);
}
/**
* Adds a property name and value to the entity to before updating.
*
* @param name the property name.
* @param value the property {@code Value}.
* @return this update statement.
*/
public Update value(final String name, final Object value) {
entity.property(name, value);
return this;
}
/**
* Adds a property name and value to the entity before updating.
*
* @param name the property name.
* @param value the property {@code Value}.
* @param indexed indicates whether the {@code Value} should be indexed or not.
* @return this update statement.
*/
public Update value(final String name, final Object value, final boolean indexed) {
entity.property(name, value, indexed);
return this;
}
/**
* Adds a property name and list of values to the entity before updating.
*
* @param name the property name.
* @param values a list of property {@code Value}s.
* @return this update statement.
*/
public Update value(final String name, final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy