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

info.archinnov.achilles.generated.dsl.EntityWithStaticAnnotations_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.EntityWithStaticAnnotations_AchillesMeta;
import info.archinnov.achilles.internals.entities.EntityWithStaticAnnotations;
import info.archinnov.achilles.internals.metamodel.AbstractEntityProperty;
import info.archinnov.achilles.internals.options.Options;
import info.archinnov.achilles.internals.query.dsl.delete.AbstractDelete;
import info.archinnov.achilles.internals.query.dsl.delete.AbstractDeleteColumns;
import info.archinnov.achilles.internals.query.dsl.delete.AbstractDeleteEnd;
import info.archinnov.achilles.internals.query.dsl.delete.AbstractDeleteFrom;
import info.archinnov.achilles.internals.query.dsl.delete.AbstractDeleteWherePartition;
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.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithStaticAnnotations_Delete extends AbstractDelete {
  protected final EntityWithStaticAnnotations_AchillesMeta meta;

  protected final Class entityClass = EntityWithStaticAnnotations.class;

  public EntityWithStaticAnnotations_Delete(RuntimeEngine rte, EntityWithStaticAnnotations_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate DELETE value ... */
  public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns stringValue() {
    delete.column("value");
    return new EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns(delete);
  }

  /**
   * Generate DELETE "overRiden" ... */
  public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns overridenName() {
    delete.column("\"overRiden\"");
    return new EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns(delete);
  }

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

  /**
   * Generate ... * FROM ... using the given SchemaNameProvider */
  public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteFrom 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 EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteFrom(where);
  }

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

    /**
     * Generate DELETE value ... */
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns stringValue() {
      delete.column("value");
      return this;
    }

    /**
     * Generate DELETE "overRiden" ... */
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteColumns overridenName() {
      delete.column("\"overRiden\"");
      return this;
    }

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

    /**
     * Generate a ... FROM xxx ... using the given SchemaNameProvider */
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteFrom 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 EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteFrom(where);
    }
  }

  public class EntityWithStaticAnnotations_DeleteFrom extends AbstractDeleteFrom {
    EntityWithStaticAnnotations_DeleteFrom(Delete.Where where) {
      super(where);
    }

    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteWhere_PartitionKey where() {
      return new EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteWhere_PartitionKey(where);
    }
  }

  public final class EntityWithStaticAnnotations_DeleteWhere_PartitionKey extends AbstractDeleteWherePartition {
    public EntityWithStaticAnnotations_DeleteWhere_PartitionKey(Delete.Where where) {
      super(where);
    }

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

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

  public final class EntityWithStaticAnnotations_DeleteEnd extends AbstractDeleteEnd {
    public EntityWithStaticAnnotations_DeleteEnd(Delete.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 EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd getThis() {
      return this;
    }

    /**
     * Generate an ... IF stringValue = ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_Eq(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(QueryBuilder.eq("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an ... IF stringValue > ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_Gt(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(QueryBuilder.gt("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an ... IF stringValue >= ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_Gte(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(QueryBuilder.gte("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an ... IF stringValue < ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_Lt(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(QueryBuilder.lt("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an ... IF stringValue <= ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_Lte(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(QueryBuilder.lte("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an  ... IF stringValue != ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifStringValue_NotEq(final String stringValue) {
      boundValues.add(stringValue);
      encodedValues.add(meta.stringValue.encodeFromJava(stringValue));
      where.onlyIf(NotEq.of("value", QueryBuilder.bindMarker("value")));
      return this;
    }

    /**
     * Generate an ... IF overridenName = ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_Eq(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(QueryBuilder.eq("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }

    /**
     * Generate an ... IF overridenName > ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_Gt(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(QueryBuilder.gt("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }

    /**
     * Generate an ... IF overridenName >= ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_Gte(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(QueryBuilder.gte("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }

    /**
     * Generate an ... IF overridenName < ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_Lt(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(QueryBuilder.lt("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }

    /**
     * Generate an ... IF overridenName <= ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_Lte(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(QueryBuilder.lte("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }

    /**
     * Generate an  ... IF overridenName != ? */
    @SuppressWarnings("static-access")
    public final EntityWithStaticAnnotations_Delete.EntityWithStaticAnnotations_DeleteEnd ifOverridenName_NotEq(final String overridenName) {
      boundValues.add(overridenName);
      encodedValues.add(meta.overridenName.encodeFromJava(overridenName));
      where.onlyIf(NotEq.of("overRiden", QueryBuilder.bindMarker("overRiden")));
      return this;
    }
  }
}