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

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

The 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.EntityWithStaticColumn_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.EntityWithStaticColumn;
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.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;

public final class EntityWithStaticColumn_UpdateStatic extends AbstractUpdate {
  protected final EntityWithStaticColumn_AchillesMeta meta;

  protected final Class entityClass = EntityWithStaticColumn.class;

  public EntityWithStaticColumn_UpdateStatic(RuntimeEngine rte, EntityWithStaticColumn_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

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

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

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

    public final Cols.StaticCol staticCol() {
      return new Cols.StaticCol();
    }

    public final Cols.AnotherStaticCol anotherStaticCol() {
      return new Cols.AnotherStaticCol();
    }

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

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

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

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

    public final F.StaticCol staticCol() {
      return new F.StaticCol();
    }

    public final F.AnotherStaticCol anotherStaticCol() {
      return new F.AnotherStaticCol();
    }

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

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

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

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

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

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

    public final E.If_StaticCol if_StaticCol() {
      return new E.If_StaticCol();
    }

    public final E.If_AnotherStaticCol if_AnotherStaticCol() {
      return new E.If_AnotherStaticCol();
    }

    public final E.If_Value if_Value() {
      return new E.If_Value();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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