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

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

package info.archinnov.achilles.generated.dsl;

import com.datastax.driver.core.querybuilder.Delete;
import com.datastax.driver.core.querybuilder.NotEq;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import info.archinnov.achilles.generated.meta.entity.EntityForAggregate_AchillesMeta;
import info.archinnov.achilles.internals.dsl.query.delete.AbstractDelete;
import info.archinnov.achilles.internals.dsl.query.delete.AbstractDeleteColumns;
import info.archinnov.achilles.internals.dsl.query.delete.AbstractDeleteEnd;
import info.archinnov.achilles.internals.dsl.query.delete.AbstractDeleteFrom;
import info.archinnov.achilles.internals.dsl.query.delete.AbstractDeleteWherePartition;
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_Delete extends AbstractDelete {
  protected final EntityForAggregate_AchillesMeta meta;

  protected final Class entityClass = EntityForAggregate.class;

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

  /**
   * Generate DELETE stringval ... */
  public final EntityForAggregate_Delete.Cols stringVal() {
    delete.column("stringval");
    return new EntityForAggregate_Delete.Cols(delete);
  }

  /**
   * Generate DELETE doubleval ... */
  public final EntityForAggregate_Delete.Cols doubleVal() {
    delete.column("doubleval");
    return new EntityForAggregate_Delete.Cols(delete);
  }

  /**
   * Generate ... * FROM ... */
  public final EntityForAggregate_Delete.F allColumns_FromBaseTable() {
    final Delete.Where where = delete.all().from(meta.getKeyspace().orElse("unknown_keyspace_for_" + meta.entityClass.getCanonicalName()), meta.getTableOrViewName()).where();
    return new EntityForAggregate_Delete.F(where, new CassandraOptions());
  }

  /**
   * Generate ... * FROM ... using the given SchemaNameProvider */
  public final EntityForAggregate_Delete.F allColumns_From(final SchemaNameProvider schemaNameProvider) {
    final String currentKeyspace = lookupKeyspace(schemaNameProvider, meta.entityClass);
    final String currentTable = lookupTable(schemaNameProvider, meta.entityClass);
    final Delete.Where where = delete.all().from(currentKeyspace, currentTable).where();
    return new EntityForAggregate_Delete.F(where, CassandraOptions.withSchemaNameProvider(schemaNameProvider));
  }

  public class Cols extends AbstractDeleteColumns {
    Cols(Delete.Selection deleteColumns) {
      super(deleteColumns);
    }

    /**
     * Generate DELETE stringval ... */
    public final EntityForAggregate_Delete.Cols stringVal() {
      delete.column("stringval");
      return this;
    }

    /**
     * Generate DELETE doubleval ... */
    public final EntityForAggregate_Delete.Cols doubleVal() {
      delete.column("doubleval");
      return this;
    }

    /**
     * Generate a ... FROM xxx ...  */
    public final EntityForAggregate_Delete.F fromBaseTable() {
      final Delete.Where where = deleteColumns.from(meta.getKeyspace().orElse("unknown_keyspace_for_" + meta.entityClass.getCanonicalName()), meta.getTableOrViewName()).where();
      return new EntityForAggregate_Delete.F(where, new CassandraOptions());
    }

    /**
     * Generate a ... FROM xxx ... using the given SchemaNameProvider */
    public final EntityForAggregate_Delete.F from(final SchemaNameProvider schemaNameProvider) {
      final String currentKeyspace = lookupKeyspace(schemaNameProvider, meta.entityClass);
      final String currentTable = lookupTable(schemaNameProvider, meta.entityClass);
      final Delete.Where where = deleteColumns.from(currentKeyspace, currentTable).where();
      return new EntityForAggregate_Delete.F(where, CassandraOptions.withSchemaNameProvider(schemaNameProvider));
    }
  }

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

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

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

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

    public final class Relation {
      /**
       * Generate a SELECT ... FROM ... WHERE ... partition = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.W_Clustering(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... partition IN ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.W_Clustering(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... partition  = fromJson(?)  */
      public final EntityForAggregate_Delete.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_Delete.W_Clustering(where, cassandraOptions);
      }
    }
  }

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

    @Override
    protected final EntityForAggregate_Delete.W_Clustering getThis() {
      return this;
    }

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

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

    @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;
    }

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

    public final class Relation {
      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E(where, cassandraOptions);
      }

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering IN ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E(where, cassandraOptions);
      }

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

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

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

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering > ? AND clustering < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.E Gt_And_Lt(Integer clustering_Gt, Integer clustering_Lt) {
        where.and(QueryBuilder.gt("clustering",QueryBuilder.bindMarker("clustering_Lt")));
        where.and(QueryBuilder.lt("clustering",QueryBuilder.bindMarker("clustering_Lt")));
        boundValues.add(clustering_Gt);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Gt, Optional.of(cassandraOptions)));
        boundValues.add(clustering_Lt);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Lt, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Delete.E(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering > ? AND clustering <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.E Gt_And_Lte(Integer clustering_Gt, Integer clustering_Lte) {
        where.and(QueryBuilder.gt("clustering",QueryBuilder.bindMarker("clustering_Lte")));
        where.and(QueryBuilder.lte("clustering",QueryBuilder.bindMarker("clustering_Lte")));
        boundValues.add(clustering_Gt);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Gt, Optional.of(cassandraOptions)));
        boundValues.add(clustering_Lte);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Lte, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Delete.E(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering >= ? AND clustering < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.E Gte_And_Lt(Integer clustering_Gte, Integer clustering_Lt) {
        where.and(QueryBuilder.gte("clustering",QueryBuilder.bindMarker("clustering_Lt")));
        where.and(QueryBuilder.lt("clustering",QueryBuilder.bindMarker("clustering_Lt")));
        boundValues.add(clustering_Gte);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Gte, Optional.of(cassandraOptions)));
        boundValues.add(clustering_Lt);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Lt, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Delete.E(where, cassandraOptions);
      }

      /**
       * Generate a SELECT ... FROM ... WHERE ... clustering >= ? AND clustering <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.E Gte_And_Lte(Integer clustering_Gte, Integer clustering_Lte) {
        where.and(QueryBuilder.gte("clustering",QueryBuilder.bindMarker("clustering_Lte")));
        where.and(QueryBuilder.lte("clustering",QueryBuilder.bindMarker("clustering_Lte")));
        boundValues.add(clustering_Gte);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Gte, Optional.of(cassandraOptions)));
        boundValues.add(clustering_Lte);
        encodedValues.add(meta.clustering.encodeFromJava(clustering_Lte, Optional.of(cassandraOptions)));
        return new EntityForAggregate_Delete.E(where, cassandraOptions);
      }
    }
  }

  public final class E extends AbstractDeleteEnd {
    public E(Delete.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_Delete.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_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF stringVal > ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF stringVal >= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF stringVal < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF stringVal <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an  ... IF stringVal != ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

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

    public final class If_DoubleVal {
      /**
       * Generate an ... IF doubleVal = ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF doubleVal > ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF doubleVal >= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF doubleVal < ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an ... IF doubleVal <= ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

      /**
       * Generate an  ... IF doubleVal != ? */
      @SuppressWarnings("static-access")
      public final EntityForAggregate_Delete.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_Delete.E.this;
      }

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