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

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

The newest version!
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.dsl.query.update.AbstractUpdate;
import info.archinnov.achilles.internals.dsl.query.update.AbstractUpdateColumns;
import info.archinnov.achilles.internals.dsl.query.update.AbstractUpdateEnd;
import info.archinnov.achilles.internals.dsl.query.update.AbstractUpdateFrom;
import info.archinnov.achilles.internals.dsl.query.update.AbstractUpdateWhere;
import info.archinnov.achilles.internals.entities.EntityWithComplexCounters;
import info.archinnov.achilles.internals.metamodel.AbstractEntityProperty;
import info.archinnov.achilles.internals.options.CassandraOptions;
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.Optional;
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.F 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.F(where, new CassandraOptions());
  }

  /**
   * Generate an UPDATE FROM ... using the given SchemaNameProvider */
  public final EntityWithComplexCounters_Update.F 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.F(where, CassandraOptions.withSchemaNameProvider(schemaNameProvider));
  }

  public class Cols extends AbstractUpdateColumns {
    Cols(Update.Where where, CassandraOptions cassandraOptions) {
      super(where, cassandraOptions);
    }

    public final Cols.StaticCounter staticCounter() {
      return new Cols.StaticCounter();
    }

    public final Cols.SimpleCounter simpleCounter() {
      return new Cols.SimpleCounter();
    }

    public final Cols.CounterWithCodec counterWithCodec() {
      return new Cols.CounterWithCodec();
    }

    public final EntityWithComplexCounters_Update.W_Id where() {
      return new EntityWithComplexCounters_Update.W_Id(where, cassandraOptions);
    }

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

      /**
       * Generate an UPDATE FROM ... SET staticCounter = staticCounter + ? */
      @SuppressWarnings("static-access")
      public final EntityWithComplexCounters_Update.Cols 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, Optional.of(cassandraOptions)));
        return EntityWithComplexCounters_Update.Cols.this;
      }

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

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

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

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

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

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

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

      /**
       * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec + ? */
      @SuppressWarnings("static-access")
      public final EntityWithComplexCounters_Update.Cols 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, Optional.of(cassandraOptions)));
        return EntityWithComplexCounters_Update.Cols.this;
      }

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

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

  public class F extends AbstractUpdateFrom {
    F(Update.Where where, CassandraOptions cassandraOptions) {
      super(where, cassandraOptions);
    }

    public final F.StaticCounter staticCounter() {
      return new F.StaticCounter();
    }

    public final F.SimpleCounter simpleCounter() {
      return new F.SimpleCounter();
    }

    public final F.CounterWithCodec counterWithCodec() {
      return new F.CounterWithCodec();
    }

    public final class StaticCounter {
      /**
       * Generate an UPDATE FROM ... SET static_count = static_count + 1 */
      public final EntityWithComplexCounters_Update.Cols Incr() {
        where.with(QueryBuilder.incr("static_count"));
        return new EntityWithComplexCounters_Update.Cols(where, cassandraOptions);
      }

      /**
       * Generate an UPDATE FROM ... SET staticCounter = staticCounter + ? */
      @SuppressWarnings("static-access")
      public final EntityWithComplexCounters_Update.Cols 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, Optional.of(cassandraOptions)));
        return new EntityWithComplexCounters_Update.Cols(where, cassandraOptions);
      }

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

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

    public final class SimpleCounter {
      /**
       * Generate an UPDATE FROM ... SET count = count + 1 */
      public final EntityWithComplexCounters_Update.Cols Incr() {
        where.with(QueryBuilder.incr("count"));
        return new EntityWithComplexCounters_Update.Cols(where, cassandraOptions);
      }

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

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

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

    public final class CounterWithCodec {
      /**
       * Generate an UPDATE FROM ... SET codec_count = codec_count + 1 */
      public final EntityWithComplexCounters_Update.Cols Incr() {
        where.with(QueryBuilder.incr("codec_count"));
        return new EntityWithComplexCounters_Update.Cols(where, cassandraOptions);
      }

      /**
       * Generate an UPDATE FROM ... SET counterWithCodec = counterWithCodec + ? */
      @SuppressWarnings("static-access")
      public final EntityWithComplexCounters_Update.Cols 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, Optional.of(cassandraOptions)));
        return new EntityWithComplexCounters_Update.Cols(where, cassandraOptions);
      }

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

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

  public final class W_Id extends AbstractUpdateWhere {
    public W_Id(Update.Where where, CassandraOptions cassandraOptions) {
      super(where, cassandraOptions);
    }

    public final EntityWithComplexCounters_Update.W_Id.Relation id() {
      return new EntityWithComplexCounters_Update.W_Id.Relation();
    }

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... id IN ? */
      @SuppressWarnings("static-access")
      public final EntityWithComplexCounters_Update.W_Uuid 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, Optional.of(cassandraOptions))).collect(Collectors.toList());
        boundValues.add(varargs);
        encodedValues.add(encodedVarargs);
        return new EntityWithComplexCounters_Update.W_Uuid(where, cassandraOptions);
      }
    }
  }

  public final class W_Uuid extends AbstractUpdateWhere {
    public W_Uuid(Update.Where where, CassandraOptions cassandraOptions) {
      super(where, cassandraOptions);
    }

    public final EntityWithComplexCounters_Update.W_Uuid.Relation uuid() {
      return new EntityWithComplexCounters_Update.W_Uuid.Relation();
    }

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

  public final class E extends AbstractUpdateEnd {
    public E(Update.Where where, CassandraOptions cassandraOptions) {
      super(where, cassandraOptions);
    }

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

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

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

    @Override
    protected final CassandraOptions getOptions() {
      return cassandraOptions;
    }

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

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

    @Override
    protected final EntityWithComplexCounters_Update.E getThis() {
      return this;
    }
  }
}