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

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

package info.archinnov.achilles.generated.dsl;

import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Update;
import info.archinnov.achilles.generated.meta.entity.EntityWithComplexCounters_AchillesMeta;
import info.archinnov.achilles.internals.entities.EntityWithComplexCounters;
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.validation.Validator;
import java.lang.Class;
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.UUID;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithComplexCounters_Update extends AbstractUpdate {
  protected final EntityWithComplexCounters_AchillesMeta meta;

  protected final Class entityClass = EntityWithComplexCounters.class;

  public EntityWithComplexCounters_Update(RuntimeEngine rte, EntityWithComplexCounters_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate an UPDATE FROM ... */
  public final EntityWithComplexCounters_Update.EntityWithComplexCounters_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 EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateFrom(where);
  }

  /**
   * Generate an UPDATE FROM ... using the given SchemaNameProvider */
  public final EntityWithComplexCounters_Update.EntityWithComplexCounters_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 EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateFrom(where);
  }

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

    /**
     * Generate an UPDATE FROM ... SET static_count = static_count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Incr() {
      where.with(QueryBuilder.incr("static_count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Incr(final Long staticCounter_increment) {
      where.with(QueryBuilder.incr("static_count", QueryBuilder.bindMarker("static_count")));
      boundValues.add(staticCounter_increment);
      encodedValues.add(meta.staticCounter.encodeFromJava(staticCounter_increment));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Decr() {
      where.with(QueryBuilder.decr("static_count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Decr(final Long staticCounter_increment) {
      where.with(QueryBuilder.decr("static_count", QueryBuilder.bindMarker("static_count")));
      boundValues.add(staticCounter_increment);
      encodedValues.add(meta.staticCounter.encodeFromJava(staticCounter_increment));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET count = count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Incr() {
      where.with(QueryBuilder.incr("count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Incr(final long simpleCounter_increment) {
      where.with(QueryBuilder.incr("count", QueryBuilder.bindMarker("count")));
      boundValues.add(simpleCounter_increment);
      encodedValues.add(meta.simpleCounter.encodeFromJava(simpleCounter_increment));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Decr() {
      where.with(QueryBuilder.decr("count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Decr(final long simpleCounter_increment) {
      where.with(QueryBuilder.decr("count", QueryBuilder.bindMarker("count")));
      boundValues.add(simpleCounter_increment);
      encodedValues.add(meta.simpleCounter.encodeFromJava(simpleCounter_increment));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET codec_count = codec_count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Incr() {
      where.with(QueryBuilder.incr("codec_count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Incr(final String counterWithCodec_increment) {
      where.with(QueryBuilder.incr("codec_count", QueryBuilder.bindMarker("codec_count")));
      boundValues.add(counterWithCodec_increment);
      encodedValues.add(meta.counterWithCodec.encodeFromJava(counterWithCodec_increment));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Decr() {
      where.with(QueryBuilder.decr("codec_count"));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Decr(final String counterWithCodec_increment) {
      where.with(QueryBuilder.decr("codec_count", QueryBuilder.bindMarker("codec_count")));
      boundValues.add(counterWithCodec_increment);
      encodedValues.add(meta.counterWithCodec.encodeFromJava(counterWithCodec_increment));
      return this;
    }

    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateWhere_Id where() {
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateWhere_Id(where);
    }
  }

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

    /**
     * Generate an UPDATE FROM ... SET static_count = static_count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Incr() {
      where.with(QueryBuilder.incr("static_count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Incr(final Long staticCounter_increment) {
      where.with(QueryBuilder.incr("static_count", QueryBuilder.bindMarker("static_count")));
      boundValues.add(staticCounter_increment);
      encodedValues.add(meta.staticCounter.encodeFromJava(staticCounter_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Decr() {
      where.with(QueryBuilder.decr("static_count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET staticCounter = staticCounter - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns staticCounter_Decr(final Long staticCounter_increment) {
      where.with(QueryBuilder.decr("static_count", QueryBuilder.bindMarker("static_count")));
      boundValues.add(staticCounter_increment);
      encodedValues.add(meta.staticCounter.encodeFromJava(staticCounter_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET count = count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Incr() {
      where.with(QueryBuilder.incr("count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Incr(final long simpleCounter_increment) {
      where.with(QueryBuilder.incr("count", QueryBuilder.bindMarker("count")));
      boundValues.add(simpleCounter_increment);
      encodedValues.add(meta.simpleCounter.encodeFromJava(simpleCounter_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Decr() {
      where.with(QueryBuilder.decr("count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET simpleCounter = simpleCounter - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns simpleCounter_Decr(final long simpleCounter_increment) {
      where.with(QueryBuilder.decr("count", QueryBuilder.bindMarker("count")));
      boundValues.add(simpleCounter_increment);
      encodedValues.add(meta.simpleCounter.encodeFromJava(simpleCounter_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET codec_count = codec_count + 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Incr() {
      where.with(QueryBuilder.incr("codec_count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec + ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Incr(final String counterWithCodec_increment) {
      where.with(QueryBuilder.incr("codec_count", QueryBuilder.bindMarker("codec_count")));
      boundValues.add(counterWithCodec_increment);
      encodedValues.add(meta.counterWithCodec.encodeFromJava(counterWithCodec_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec - 1 */
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Decr() {
      where.with(QueryBuilder.decr("codec_count"));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec - ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns counterWithCodec_Decr(final String counterWithCodec_increment) {
      where.with(QueryBuilder.decr("codec_count", QueryBuilder.bindMarker("codec_count")));
      boundValues.add(counterWithCodec_increment);
      encodedValues.add(meta.counterWithCodec.encodeFromJava(counterWithCodec_increment));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateColumns(where);
    }
  }

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

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

    /**
     * Generate a SELECT ... FROM ... WHERE ... id IN ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateWhere_Uuid 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 EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateWhere_Uuid(where);
    }
  }

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

    /**
     * Generate a SELECT ... FROM ... WHERE ... uuid = ? */
    @SuppressWarnings("static-access")
    public final EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateEnd uuid_Eq(UUID uuid) {
      where.and(QueryBuilder.eq("uuid", QueryBuilder.bindMarker("uuid_Eq")));
      boundValues.add(uuid);
      encodedValues.add(meta.uuid.encodeFromJava(uuid));
      return new EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateEnd(where);
    }
  }

  public final class EntityWithComplexCounters_UpdateEnd extends AbstractUpdateEnd {
    public EntityWithComplexCounters_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 EntityWithComplexCounters_Update.EntityWithComplexCounters_UpdateEnd getThis() {
      return this;
    }
  }
}