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

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

package info.archinnov.achilles.generated.dsl;

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.EntityAsChild_AchillesMeta;
import info.archinnov.achilles.internals.entities.EntityAsChild;
import info.archinnov.achilles.internals.metamodel.AbstractEntityProperty;
import info.archinnov.achilles.internals.options.Options;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdate;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateColumns;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateEnd;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateFrom;
import info.archinnov.achilles.internals.query.dsl.update.AbstractUpdateWhere;
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 EntityAsChild_Update extends AbstractUpdate {
  protected final EntityAsChild_AchillesMeta meta;

  protected final Class entityClass = EntityAsChild.class;

  public EntityAsChild_Update(RuntimeEngine rte, EntityAsChild_AchillesMeta meta) {
    super(rte);
    this.meta = meta;
  }

  /**
   * Generate an UPDATE FROM ... */
  public final EntityAsChild_Update.EntityAsChild_UpdateFrom 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 EntityAsChild_Update.EntityAsChild_UpdateFrom(where);
  }

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

  public class EntityAsChild_UpdateColumns extends AbstractUpdateColumns {
    EntityAsChild_UpdateColumns(Update.Where where) {
      super(where);
    }

    /**
     * Generate an UPDATE FROM ... SET value = ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateColumns value_Set(final String value) {
      where.with(QueryBuilder.set("value", QueryBuilder.bindMarker("value")));
      boundValues.add(value);
      encodedValues.add(meta.value.encodeFromJava(value));
      return this;
    }

    /**
     * Generate an UPDATE FROM ... SET child_value = ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateColumns anotherValue_Set(final String anotherValue) {
      where.with(QueryBuilder.set("child_value", QueryBuilder.bindMarker("child_value")));
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      return this;
    }

    public final EntityAsChild_Update.EntityAsChild_UpdateWhere_Id where() {
      return new EntityAsChild_Update.EntityAsChild_UpdateWhere_Id(where);
    }
  }

  public class EntityAsChild_UpdateFrom extends AbstractUpdateFrom {
    EntityAsChild_UpdateFrom(Update.Where where) {
      super(where);
    }

    /**
     * Generate an UPDATE FROM ... SET value = ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateColumns value_Set(final String value) {
      where.with(QueryBuilder.set("value", QueryBuilder.bindMarker("value")));
      boundValues.add(value);
      encodedValues.add(meta.value.encodeFromJava(value));
      return new EntityAsChild_Update.EntityAsChild_UpdateColumns(where);
    }

    /**
     * Generate an UPDATE FROM ... SET child_value = ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateColumns anotherValue_Set(final String anotherValue) {
      where.with(QueryBuilder.set("child_value", QueryBuilder.bindMarker("child_value")));
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      return new EntityAsChild_Update.EntityAsChild_UpdateColumns(where);
    }
  }

  public final class EntityAsChild_UpdateWhere_Id extends AbstractUpdateWhere {
    public EntityAsChild_UpdateWhere_Id(Update.Where where) {
      super(where);
    }

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

    /**
     * Generate a SELECT ... FROM ... WHERE ... id IN ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd id_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)).collect(Collectors.toList());
      boundValues.add(varargs);
      encodedValues.add(encodedVarargs);
      return new EntityAsChild_Update.EntityAsChild_UpdateEnd(where);
    }
  }

  public final class EntityAsChild_UpdateEnd extends AbstractUpdateEnd {
    public EntityAsChild_UpdateEnd(Update.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 EntityAsChild_Update.EntityAsChild_UpdateEnd getThis() {
      return this;
    }

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

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

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

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

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

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

    /**
     * Generate an ... IF anotherValue = ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_Eq(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(QueryBuilder.eq("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }

    /**
     * Generate an ... IF anotherValue > ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_Gt(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(QueryBuilder.gt("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }

    /**
     * Generate an ... IF anotherValue >= ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_Gte(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(QueryBuilder.gte("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }

    /**
     * Generate an ... IF anotherValue < ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_Lt(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(QueryBuilder.lt("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }

    /**
     * Generate an ... IF anotherValue <= ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_Lte(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(QueryBuilder.lte("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }

    /**
     * Generate an  ... IF anotherValue != ? */
    @SuppressWarnings("static-access")
    public final EntityAsChild_Update.EntityAsChild_UpdateEnd ifAnotherValue_NotEq(final String anotherValue) {
      boundValues.add(anotherValue);
      encodedValues.add(meta.anotherValue.encodeFromJava(anotherValue));
      where.onlyIf(NotEq.of("child_value", QueryBuilder.bindMarker("child_value")));
      return this;
    }
  }
}