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

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

There is a newer version: 6.1.0
Show newest version
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.EntityWithDSESearch_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.EntityWithDSESearch;
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.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithDSESearch_Update extends AbstractUpdate {
  protected final EntityWithDSESearch_AchillesMeta meta;

  protected final Class entityClass = EntityWithDSESearch.class;

  public EntityWithDSESearch_Update(RuntimeEngine rte, EntityWithDSESearch_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

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

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

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

    public final Cols.String string() {
      return new Cols.String();
    }

    public final Cols.Numeric numeric() {
      return new Cols.Numeric();
    }

    public final Cols.Date date() {
      return new Cols.Date();
    }

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

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

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

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

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

    public final F.String string() {
      return new F.String();
    }

    public final F.Numeric numeric() {
      return new F.Numeric();
    }

    public final F.Date date() {
      return new F.Date();
    }

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

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

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

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

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

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

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

    public final E.If_String if_String() {
      return new E.If_String();
    }

    public final E.If_Numeric if_Numeric() {
      return new E.If_Numeric();
    }

    public final E.If_Date if_Date() {
      return new E.If_Date();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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