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

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

The newest version!
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.EntityWithNativeCollections_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.EntityWithNativeCollections;
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.type.tuples.Tuple2;
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.SuppressWarnings;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithNativeCollections_Delete extends AbstractDelete {
  protected final EntityWithNativeCollections_AchillesMeta meta;

  protected final Class entityClass = EntityWithNativeCollections.class;

  public EntityWithNativeCollections_Delete(RuntimeEngine rte, EntityWithNativeCollections_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate DELETE longlist ... */
  public final EntityWithNativeCollections_Delete.Cols longList() {
    delete.column("longlist");
    return new EntityWithNativeCollections_Delete.Cols(delete);
  }

  /**
   * Generate DELETE doublelist ... */
  public final EntityWithNativeCollections_Delete.Cols doubleList() {
    delete.column("doublelist");
    return new EntityWithNativeCollections_Delete.Cols(delete);
  }

  /**
   * Generate DELETE mapintlong ... */
  public final EntityWithNativeCollections_Delete.Cols mapIntLong() {
    delete.column("mapintlong");
    return new EntityWithNativeCollections_Delete.Cols(delete);
  }

  /**
   * Generate DELETE tuple2 ... */
  public final EntityWithNativeCollections_Delete.Cols tuple2() {
    delete.column("tuple2");
    return new EntityWithNativeCollections_Delete.Cols(delete);
  }

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

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

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

    /**
     * Generate DELETE longlist ... */
    public final EntityWithNativeCollections_Delete.Cols longList() {
      delete.column("longlist");
      return this;
    }

    /**
     * Generate DELETE doublelist ... */
    public final EntityWithNativeCollections_Delete.Cols doubleList() {
      delete.column("doublelist");
      return this;
    }

    /**
     * Generate DELETE mapintlong ... */
    public final EntityWithNativeCollections_Delete.Cols mapIntLong() {
      delete.column("mapintlong");
      return this;
    }

    /**
     * Generate DELETE tuple2 ... */
    public final EntityWithNativeCollections_Delete.Cols tuple2() {
      delete.column("tuple2");
      return this;
    }

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

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

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

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

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

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

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... id IN ? */
      @SuppressWarnings("static-access")
      public final EntityWithNativeCollections_Delete.E 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 EntityWithNativeCollections_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 EntityWithNativeCollections_Delete.E getThis() {
      return this;
    }

    public final E.If_LongList if_LongList() {
      return new E.If_LongList();
    }

    public final E.If_DoubleList if_DoubleList() {
      return new E.If_DoubleList();
    }

    public final E.If_MapIntLong if_MapIntLong() {
      return new E.If_MapIntLong();
    }

    public final E.If_Tuple2 if_Tuple2() {
      return new E.If_Tuple2();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public final class If_Tuple2 {
      /**
       * Generate an ... IF tuple2 = ? */
      @SuppressWarnings("static-access")
      public final EntityWithNativeCollections_Delete.E Eq(final Tuple2, List> tuple2) {
        boundValues.add(tuple2);
        encodedValues.add(meta.tuple2.encodeFromJava(tuple2, Optional.of(cassandraOptions)));
        where.onlyIf(QueryBuilder.eq("tuple2", QueryBuilder.bindMarker("tuple2")));
        return EntityWithNativeCollections_Delete.E.this;
      }

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

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

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

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

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