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

info.archinnov.achilles.generated.dsl.EntityWithComplexTuple_Update Maven / Gradle / Ivy

There is a newer version: 4.2.3
Show newest version
package info.archinnov.achilles.generated.dsl;

import com.datastax.driver.core.querybuilder.NotEq;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Update;
import info.archinnov.achilles.generated.meta.entity.EntityWithComplexTuple_AchillesMeta;
import info.archinnov.achilles.internals.entities.EntityWithComplexTuple;
import info.archinnov.achilles.internals.metamodel.AbstractEntityProperty;
import info.archinnov.achilles.internals.options.Options;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdate;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateColumns;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateEnd;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateFrom;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateWhere;
import info.archinnov.achilles.internals.runtime.RuntimeEngine;
import info.archinnov.achilles.type.SchemaNameProvider;
import info.archinnov.achilles.type.tuples.Tuple2;
import info.archinnov.achilles.validation.Validator;
import java.lang.Class;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithComplexTuple_Update extends AbstractUpdate {
  protected final EntityWithComplexTuple_AchillesMeta meta;

  protected final Class entityClass = EntityWithComplexTuple.class;

  public EntityWithComplexTuple_Update(RuntimeEngine rte, EntityWithComplexTuple_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate an UPDATE FROM ... */
  public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateFrom fromBaseTable() {
    final String currentKeyspace = meta.getKeyspace().orElse("unknown_keyspace_for_" + meta.entityClass.getCanonicalName());
    final Update.Where where = QueryBuilder.update(currentKeyspace, meta.getTableOrViewName()).where();
    return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateFrom(where);
  }

  /**
   * Generate an UPDATE FROM ... using the given SchemaNameProvider */
  public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateFrom from(final SchemaNameProvider schemaNameProvider) {
    final String currentKeyspace = lookupKeyspace(schemaNameProvider, meta.entityClass);
    final String currentTable = lookupTable(schemaNameProvider, meta.entityClass);
    final Update.Where where = QueryBuilder.update(currentKeyspace, currentTable).where();
    return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateFrom(where);
  }

  public class EntityWithComplexTuple_UpdateColumns extends AbstractUpdateColumns {
    EntityWithComplexTuple_UpdateColumns(Update.Where where) {
      super(where);
    }

    /**
     * Generate an UPDATE FROM ... SET tuple = ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateColumns tuple_Set(final Tuple2>> tuple) {
      where.with(QueryBuilder.set("tuple", QueryBuilder.bindMarker("tuple")));
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      return this;
    }

    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateWhere_Id where() {
      return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateWhere_Id(where);
    }
  }

  public class EntityWithComplexTuple_UpdateFrom extends AbstractUpdateFrom {
    EntityWithComplexTuple_UpdateFrom(Update.Where where) {
      super(where);
    }

    /**
     * Generate an UPDATE FROM ... SET tuple = ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateColumns tuple_Set(final Tuple2>> tuple) {
      where.with(QueryBuilder.set("tuple", QueryBuilder.bindMarker("tuple")));
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateColumns(where);
    }
  }

  public final class EntityWithComplexTuple_UpdateWhere_Id extends AbstractUpdateWhere {
    public EntityWithComplexTuple_UpdateWhere_Id(Update.Where where) {
      super(where);
    }

    /**
     * Generate a SELECT ... FROM ... WHERE ... id = ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd id_Eq(Long id) {
      where.and(QueryBuilder.eq("id", QueryBuilder.bindMarker("id_Eq")));
      boundValues.add(id);
      encodedValues.add(meta.id.encodeFromJava(id));
      return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd(where);
    }

    /**
     * Generate a SELECT ... FROM ... WHERE ... id IN ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd id_IN(Long... id) {
      Validator.validateTrue(ArrayUtils.isNotEmpty(id), "Varargs for field '%s' should not be null/empty", "id");
      where.and(QueryBuilder.in("id",QueryBuilder.bindMarker("id")));
      final List varargs = Arrays.asList((Object[])id);
      final List encodedVarargs = Arrays.stream((Long[])id).map(x -> meta.id.encodeFromJava(x)).collect(Collectors.toList());
      boundValues.add(varargs);
      encodedValues.add(encodedVarargs);
      return new EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd(where);
    }
  }

  public final class EntityWithComplexTuple_UpdateEnd extends AbstractUpdateEnd {
    public EntityWithComplexTuple_UpdateEnd(Update.Where where) {
      super(where);
    }

    @Override
    protected final Class getEntityClass() {
      return entityClass;
    }

    @Override
    protected final AbstractEntityProperty getMetaInternal() {
      return meta;
    }

    @Override
    protected final RuntimeEngine getRte() {
      return rte;
    }

    @Override
    protected final Options getOptions() {
      return options;
    }

    @Override
    protected final List getBoundValuesInternal() {
      return boundValues;
    }

    @Override
    protected final List getEncodedValuesInternal() {
      return encodedValues;
    }

    @Override
    protected final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd getThis() {
      return this;
    }

    /**
     * Generate an ... IF tuple = ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_Eq(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(QueryBuilder.eq("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }

    /**
     * Generate an ... IF tuple > ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_Gt(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(QueryBuilder.gt("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }

    /**
     * Generate an ... IF tuple >= ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_Gte(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(QueryBuilder.gte("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }

    /**
     * Generate an ... IF tuple < ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_Lt(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(QueryBuilder.lt("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }

    /**
     * Generate an ... IF tuple <= ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_Lte(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(QueryBuilder.lte("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }

    /**
     * Generate an  ... IF tuple != ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexTuple_Update.EntityWithComplexTuple_UpdateEnd ifTuple_NotEq(final Tuple2>> tuple) {
      boundValues.add(tuple);
      encodedValues.add(meta.tuple.encodeFromJava(tuple));
      where.onlyIf(NotEq.of("tuple", QueryBuilder.bindMarker("tuple")));
      return this;
    }
  }
}