All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.helenusdriver.driver.Update Maven / Gradle / Ivy

Go to download

JPA-like syntax for annotating POJO classes for persistence via Cassandra's Java driver - API

The newest version!
/*
 * Copyright (C) 2015-2015 The Helenus Driver Project Authors.
 *
 * 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.github.helenusdriver.driver;


/**
 * The Update interface extends the functionality of Cassandra's
 * {@link com.datastax.driver.core.querybuilder.Update} class to provide support
 * for POJOs.
 *
 * @copyright 2015-2015 The Helenus Driver Project Authors
 *
 * @author  The Helenus Driver Project Authors
 * @version 1 - Jan 15, 2015 - paouelle - Creation
 *
 * @param  The type of POJO associated with this statement.
 *
 * @since 1.0
 */
public interface Update
  extends Statement, BatchableStatement {
  /**
   * Adds an assignment to this UPDATE statement.
   *
   * This is a shorter/more readable version for {@code with().and(assignments)}.
   *
   * @author paouelle
   *
   * @param  assignments the assignments to add.
   * @return the Assignments of this UPDATE statement.
   * @throws IllegalArgumentException if the assignment references a column
   *         not defined in the POJO
   */
  public Assignments with(Assignment... assignments);

  /**
   * Returns the assignments of this UPDATE statement.
   *
   * @author paouelle
   *
   * @return the assignments of this UPDATE statement.
   */
  public Assignments with();

  /**
   * Adds a WHERE clause to this statement.
   *
   * This is a shorter/more readable version for {@code where().and(clauses)}.
   *
   * @author paouelle
   *
   * @param  clause the clause to add.
   * @return the where clause of this query to which more clause can be added.
   * @throws IllegalArgumentException if the clause references a column
   *         not defined in the POJO
   */
  public Where where(Clause clause);

  /**
   * Returns a Where statement for this query without adding clause.
   *
   * @author paouelle
   *
   * @return the where clause of this query to which more clause can be added.
   */
  public Where where();

  /**
   * Adds a conditions clause (IF) to this statement.
   * 

* This is a shorter/more readable version for {@code onlyIf().and(condition)}. * * @param condition the condition to add. * @return the conditions of this query to which more conditions can be added. * @throws IllegalArgumentException if the condition reference a column not * defined by the POJO */ public Conditions onlyIf(Clause.Equality condition); /** * Adds a conditions clause (IF) to this statement. * * @return the conditions of this query to which more conditions can be added. */ public Conditions onlyIf(); /** * Adds a new options for this UPDATE statement. * * @param using the option to add. * @return the options of this UPDATE statement. */ public Options using(Using using); /** * The Assignments interface defines the assignments of an UPDATE * statement. * * @copyright 2015-2015 The Helenus Driver Project Authors * * @author The Helenus Driver Project Authors * @version 1 - Jan 15, 2015 - paouelle - Creation * * @param The type of POJO associated with the statement. * * @since 1.0 */ public interface Assignments extends Statement, BatchableStatement { /** * Adds a new assignment for this UPDATE statement. * * @author paouelle * * @param assignments the assignments to add. * @return these Assignments. * @throws IllegalArgumentException if the assignment references a column * not defined in the POJO */ public Assignments and(Assignment... assignments); /** * Adds a WHERE clause to the UPDATE statement those assignments are part * of. * * @author paouelle * * @param clause the clause to add. * @return the WHERE clause of the UPDATE statement those assignments are * part of. * @throws IllegalArgumentException if the clause referenced a * column which is not a primary key or an index column in the POJO * or if the clause references columns not defined by the POJO or * invalid values */ public Where where(Clause clause); /** * Adds an option to the UPDATE statement those assignments are part of. * * @author paouelle * * @param using the using clause to add. * @return the options of the UPDATE statement those assignments are part * of. */ public Options using(Using using); /** * Adds a condition to the UPDATE statement those assignments are part of. * * @author paouelle * * @param condition the condition to add. * @return the conditions for the UPDATE statement those assignments are * part of. * @throws IllegalArgumentException if the condition reference a column not * defined by the POJO */ public Conditions onlyIf(Clause.Equality condition); } /** * The Where interface defines a WHERE clause for an UPDATE statement. * * @copyright 2015-2015 The Helenus Driver Project Authors * * @author The Helenus Driver Project Authors * @version 1 - Jan 15, 2015 - paouelle - Creation * * @param The type of POJO associated with the statement. * * @since 1.0 */ public interface Where extends Statement, BatchableStatement { /** * Adds the provided clause to this WHERE clause. * * @author paouelle * * @param clause the clause to add. * @return this WHERE clause. * @throws IllegalArgumentException if the clause references a column * not defined in the POJO */ public Where and(Clause clause); /** * Adds an assignment to the UPDATE statement this WHERE clause is part of. * * @author paouelle * * @param assignments the assignments to add. * @return the assignments of the UPDATE statement this WHERE clause is part * of. * @throws IllegalArgumentException if the assignment references a column * not defined in the POJO */ public Assignments with(Assignment... assignments); /** * Adds an option to the UPDATE statement this WHERE clause is part of. * * @author paouelle * * @param using the using clause to add. * @return the options of the UPDATE statement this WHERE clause is part of. */ public Options using(Using using); /** * Adds a condition to the UPDATE statement this WHERE clause is part of. * * @author paouelle * * @param condition the condition to add. * @return the conditions for the UPDATE statement this WHERE clause is part * of. * @throws IllegalArgumentException if the condition reference a column not * defined by the POJO */ public Conditions onlyIf(Clause.Equality condition); } /** * The Options interface defines the options of an UPDATE statement. * * @copyright 2015-2015 The Helenus Driver Project Authors * * @author The Helenus Driver Project Authors * @version 1 - Jan 15, 2015 - paouelle - Creation * * @param The type of POJO associated with the statement. * * @since 1.0 */ public interface Options extends Statement, BatchableStatement { /** * Adds the provided option. * * @author paouelle * * @param using an UPDATE option. * @return this {@code Options} object. */ public Options and(Using using); /** * Adds an assignment to the UPDATE statement those options are part of. * * @author paouelle * * @param assignments the assignments to add. * @return the assignments of the UPDATE statement those options are part * of. * @throws IllegalArgumentException if the assignment references a column * not defined in the POJO */ public Assignments with(Assignment... assignments); /** * Adds a condition to the UPDATE statement these options are part of. * * @author paouelle * * @param condition the condition to add. * @return the conditions for the UPDATE statement these options are part * of. * @throws IllegalArgumentException if the condition reference a column not * defined by the POJO */ public Conditions onlyIf(Clause.Equality condition); } /** * Conditions for an UDPATE statement. *

* When provided some conditions, an update will not apply unless the provided * conditions applies. *

* Please keep in mind that provided conditions has a non negligible * performance impact and should be avoided when possible. * * @copyright 2015-2015 The Helenus Driver Project Authors * * @author The Helenus Driver Project Authors * @version 1 - Jan 15, 2015 - paouelle - Creation * * @param The type of POJO associated with the statement. * * @since 1.0 */ public interface Conditions extends Statement, BatchableStatement { /** * Adds the provided condition for the update. * * @author paouelle * * @param condition the condition to add. * @return this {@code Conditions} clause. * @throws IllegalArgumentException if the condition reference a column not * defined by the POJO */ public Conditions and(Clause.Equality condition); /** * Adds an assignment to the UPDATE statement those conditions are part of. * * @author paouelle * * @param assignments the assignments to add. * @return the assignments of the UPDATE statement those conditions are part * of. * @throws IllegalArgumentException if the assignment references a column * is not defined in the POJO or invalid values or if missing * mandatory columns are referenced by the new assignment */ public Assignments with(Assignment... assignments); /** * Adds a where clause to the UPDATE statement these options are part of. * * @param clause clause to add. * @return the WHERE clause of the UPDATE statement these options are part * of. * @throws IllegalArgumentException if the clause referenced a * column which is not a primary key or an index column in the POJO * or if the clause references columns not defined by the POJO or * invalid values */ public Where where(Clause clause); /** * Adds an option to the UPDATE statement these conditions are part of. * * @param using the using clause to add. * @return the options of the UPDATE statement these conditions are part of. */ public Options using(Using using); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy