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

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

package info.archinnov.achilles.generated.dsl;

import com.datastax.driver.core.querybuilder.NonEscapingSetAssignment;
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.EntityForAggregate_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.EntityForAggregate;
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.Double;
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.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityForAggregate_Update extends AbstractUpdate {
  protected final EntityForAggregate_AchillesMeta meta;

  protected final Class entityClass = EntityForAggregate.class;

  public EntityForAggregate_Update(RuntimeEngine rte, EntityForAggregate_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate an UPDATE FROM ... */
  public final EntityForAggregate_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 EntityForAggregate_Update.F(where, new CassandraOptions());
  }

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

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

    public final Cols.StringVal stringVal() {
      return new Cols.StringVal();
    }

    public final Cols.DoubleVal doubleVal() {
      return new Cols.DoubleVal();
    }

    public final EntityForAggregate_Update.W_Partition where() {
      return new EntityForAggregate_Update.W_Partition(where, cassandraOptions);
    }

    public final class StringVal {
      /**
       * Generate an UPDATE FROM ... SET stringval = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.Cols Set(final String stringVal) {
        where.with(NonEscapingSetAssignment.of("stringval", QueryBuilder.bindMarker("stringval")));
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        return EntityForAggregate_Update.Cols.this;
      }

      /**
       * Generate an UPDATE FROM ... SET stringval = fromJson(?) */
      public final EntityForAggregate_Update.Cols Set_FromJSON(final String stringVal_element) {
        where.with(NonEscapingSetAssignment.of("stringval", QueryBuilder.fromJson(QueryBuilder.bindMarker("stringval"))));
        boundValues.add(stringVal_element);
        encodedValues.add(stringVal_element);
        return EntityForAggregate_Update.Cols.this;
      }
    }

    public final class DoubleVal {
      /**
       * Generate an UPDATE FROM ... SET doubleval = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.Cols Set(final Double doubleVal) {
        where.with(NonEscapingSetAssignment.of("doubleval", QueryBuilder.bindMarker("doubleval")));
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        return EntityForAggregate_Update.Cols.this;
      }

      /**
       * Generate an UPDATE FROM ... SET doubleval = fromJson(?) */
      public final EntityForAggregate_Update.Cols Set_FromJSON(final String doubleVal_element) {
        where.with(NonEscapingSetAssignment.of("doubleval", QueryBuilder.fromJson(QueryBuilder.bindMarker("doubleval"))));
        boundValues.add(doubleVal_element);
        encodedValues.add(doubleVal_element);
        return EntityForAggregate_Update.Cols.this;
      }
    }
  }

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

    public final F.StringVal stringVal() {
      return new F.StringVal();
    }

    public final F.DoubleVal doubleVal() {
      return new F.DoubleVal();
    }

    public final class StringVal {
      /**
       * Generate an UPDATE FROM ... SET stringval = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.Cols Set(final String stringVal) {
        where.with(NonEscapingSetAssignment.of("stringval", QueryBuilder.bindMarker("stringval")));
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Update.Cols(where, cassandraOptions);
      }

      /**
       * Generate an UPDATE FROM ... SET stringval = fromJson(?) */
      public final EntityForAggregate_Update.Cols Set_FromJSON(final String stringVal_element) {
        where.with(NonEscapingSetAssignment.of("stringval", QueryBuilder.fromJson(QueryBuilder.bindMarker("stringval"))));
        boundValues.add(stringVal_element);
        encodedValues.add(stringVal_element);
        return new EntityForAggregate_Update.Cols(where, cassandraOptions);
      }
    }

    public final class DoubleVal {
      /**
       * Generate an UPDATE FROM ... SET doubleval = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.Cols Set(final Double doubleVal) {
        where.with(NonEscapingSetAssignment.of("doubleval", QueryBuilder.bindMarker("doubleval")));
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Update.Cols(where, cassandraOptions);
      }

      /**
       * Generate an UPDATE FROM ... SET doubleval = fromJson(?) */
      public final EntityForAggregate_Update.Cols Set_FromJSON(final String doubleVal_element) {
        where.with(NonEscapingSetAssignment.of("doubleval", QueryBuilder.fromJson(QueryBuilder.bindMarker("doubleval"))));
        boundValues.add(doubleVal_element);
        encodedValues.add(doubleVal_element);
        return new EntityForAggregate_Update.Cols(where, cassandraOptions);
      }
    }
  }

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

    public final EntityForAggregate_Update.W_Partition.Relation partition() {
      return new EntityForAggregate_Update.W_Partition.Relation();
    }

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

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... partition  = fromJson(?)  */
      public final EntityForAggregate_Update.W_Clustering Eq_FromJson(String partition) {
        where.and(QueryBuilder.eq("partition", QueryBuilder.fromJson(QueryBuilder.bindMarker("partition"))));
        boundValues.add(partition);
        encodedValues.add(partition);
        return new EntityForAggregate_Update.W_Clustering(where, cassandraOptions);
      }
    }
  }

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

    public final EntityForAggregate_Update.W_Clustering.Relation clustering() {
      return new EntityForAggregate_Update.W_Clustering.Relation();
    }

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering  = fromJson(?)  */
      public final EntityForAggregate_Update.E Eq_FromJson(String clustering) {
        where.and(QueryBuilder.eq("clustering", QueryBuilder.fromJson(QueryBuilder.bindMarker("clustering"))));
        boundValues.add(clustering);
        encodedValues.add(clustering);
        return new EntityForAggregate_Update.E(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering IN ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E IN(Integer... clustering) {
        Validator.validateTrue(ArrayUtils.isNotEmpty(clustering), "Varargs for field '%s' should not be null/empty", "clustering");
        where.and(QueryBuilder.in("clustering",QueryBuilder.bindMarker("clustering")));
        final List varargs = Arrays.asList((Object[])clustering);
        final List encodedVarargs = Arrays.stream((Integer[])clustering).map(x -> meta.clustering.encodeFromJava(x, Optional.of(cassandraOptions))).collect(Collectors.toList());
        boundValues.add(varargs);
        encodedValues.add(encodedVarargs);
        return new EntityForAggregate_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 EntityForAggregate_Update.E getThis() {
      return this;
    }

    public final E.If_StringVal if_StringVal() {
      return new E.If_StringVal();
    }

    public final E.If_DoubleVal if_DoubleVal() {
      return new E.If_DoubleVal();
    }

    public final class If_StringVal {
      /**
       * Generate an ... IF stringVal = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Eq(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.eq("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF stringVal > ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Gt(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.gt("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF stringVal >= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Gte(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.gte("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF stringVal < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Lt(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.lt("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF stringVal <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Lte(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.lte("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an  ... IF stringVal != ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E NotEq(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(meta.stringVal.encodeFromJava(stringVal, Optional.of(cassandraOptions)));
        where.onlyIf(NotEq.of("stringval", QueryBuilder.bindMarker("stringval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF stringVal = fromJson(?) */
      public final EntityForAggregate_Update.E Eq_FromJSON(final String stringVal) {
        boundValues.add(stringVal);
        encodedValues.add(stringVal);
        where.onlyIf(QueryBuilder.eq("stringval", QueryBuilder.fromJson(QueryBuilder.bindMarker("stringval"))));
        return EntityForAggregate_Update.E.this;
      }
    }

    public final class If_DoubleVal {
      /**
       * Generate an ... IF doubleVal = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Eq(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.eq("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF doubleVal > ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Gt(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.gt("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF doubleVal >= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Gte(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.gte("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF doubleVal < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Lt(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.lt("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF doubleVal <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E Lte(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.lte("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an  ... IF doubleVal != ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Update.E NotEq(final Double doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(meta.doubleVal.encodeFromJava(doubleVal, Optional.of(cassandraOptions)));
        where.onlyIf(NotEq.of("doubleval", QueryBuilder.bindMarker("doubleval")));
        return EntityForAggregate_Update.E.this;
      }

      /**
       * Generate an ... IF doubleVal = fromJson(?) */
      public final EntityForAggregate_Update.E Eq_FromJSON(final String doubleVal) {
        boundValues.add(doubleVal);
        encodedValues.add(doubleVal);
        where.onlyIf(QueryBuilder.eq("doubleval", QueryBuilder.fromJson(QueryBuilder.bindMarker("doubleval"))));
        return EntityForAggregate_Update.E.this;
      }
    }
  }
}