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

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

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.EntitySensor_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.EntitySensor;
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.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 EntitySensor_Update extends AbstractUpdate {
  protected final EntitySensor_AchillesMeta meta;

  protected final Class entityClass = EntitySensor.class;

  public EntitySensor_Update(RuntimeEngine rte, EntitySensor_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

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

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

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

    public final Cols.Type type() {
      return new Cols.Type();
    }

    public final Cols.Value value() {
      return new Cols.Value();
    }

    public final EntitySensor_Update.W_SensorId where() {
      return new EntitySensor_Update.W_SensorId(where, cassandraOptions);
    }

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

      /**
       * Generate an UPDATE FROM ... SET type = fromJson(?) */
      public final EntitySensor_Update.Cols Set_FromJSON(final String type_element) {
        where.with(NonEscapingSetAssignment.of("type", QueryBuilder.fromJson(QueryBuilder.bindMarker("type"))));
        boundValues.add(type_element);
        encodedValues.add(type_element);
        return EntitySensor_Update.Cols.this;
      }
    }

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

      /**
       * Generate an UPDATE FROM ... SET value = fromJson(?) */
      public final EntitySensor_Update.Cols Set_FromJSON(final String value_element) {
        where.with(NonEscapingSetAssignment.of("value", QueryBuilder.fromJson(QueryBuilder.bindMarker("value"))));
        boundValues.add(value_element);
        encodedValues.add(value_element);
        return EntitySensor_Update.Cols.this;
      }
    }
  }

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

    public final F.Type type() {
      return new F.Type();
    }

    public final F.Value value() {
      return new F.Value();
    }

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

      /**
       * Generate an UPDATE FROM ... SET type = fromJson(?) */
      public final EntitySensor_Update.Cols Set_FromJSON(final String type_element) {
        where.with(NonEscapingSetAssignment.of("type", QueryBuilder.fromJson(QueryBuilder.bindMarker("type"))));
        boundValues.add(type_element);
        encodedValues.add(type_element);
        return new EntitySensor_Update.Cols(where, cassandraOptions);
      }
    }

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

      /**
       * Generate an UPDATE FROM ... SET value = fromJson(?) */
      public final EntitySensor_Update.Cols Set_FromJSON(final String value_element) {
        where.with(NonEscapingSetAssignment.of("value", QueryBuilder.fromJson(QueryBuilder.bindMarker("value"))));
        boundValues.add(value_element);
        encodedValues.add(value_element);
        return new EntitySensor_Update.Cols(where, cassandraOptions);
      }
    }
  }

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

    public final EntitySensor_Update.W_SensorId.Relation sensorId() {
      return new EntitySensor_Update.W_SensorId.Relation();
    }

    public final class Relation {
      /**
       * Generate a SELECT ... FROM ... WHERE ... sensor_id = ? */
      @SuppressWarnings("static-access")
      public final EntitySensor_Update.W_Date Eq(Long sensorId) {
        where.and(QueryBuilder.eq("sensor_id", QueryBuilder.bindMarker("sensor_id")));
        boundValues.add(sensorId);
        encodedValues.add(meta.sensorId.encodeFromJava(sensorId, Optional.of(cassandraOptions)));
        return new EntitySensor_Update.W_Date(where, cassandraOptions);
      }

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

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

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

    public final EntitySensor_Update.W_Date.Relation date() {
      return new EntitySensor_Update.W_Date.Relation();
    }

    public final class Relation {
      /**
       * Generate a SELECT ... FROM ... WHERE ... date = ? */
      @SuppressWarnings("static-access")
      public final EntitySensor_Update.E Eq(Long date) {
        where.and(QueryBuilder.eq("date", QueryBuilder.bindMarker("date")));
        boundValues.add(date);
        encodedValues.add(meta.date.encodeFromJava(date, Optional.of(cassandraOptions)));
        return new EntitySensor_Update.E(where, cassandraOptions);
      }

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

      /**
       * Generate a SELECT ... FROM ... WHERE ... date IN ? */
      @SuppressWarnings("static-access")
      public final EntitySensor_Update.E IN(Long... date) {
        Validator.validateTrue(ArrayUtils.isNotEmpty(date), "Varargs for field '%s' should not be null/empty", "date");
        where.and(QueryBuilder.in("date",QueryBuilder.bindMarker("date")));
        final List varargs = Arrays.asList((Object[])date);
        final List encodedVarargs = Arrays.stream((Long[])date).map(x -> meta.date.encodeFromJava(x, Optional.of(cassandraOptions))).collect(Collectors.toList());
        boundValues.add(varargs);
        encodedValues.add(encodedVarargs);
        return new EntitySensor_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 EntitySensor_Update.E getThis() {
      return this;
    }

    public final E.If_Type if_Type() {
      return new E.If_Type();
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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