package info.archinnov.achilles.generated;

import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Row;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.reflect.TypeToken;
import info.archinnov.achilles.generated.function.Long_Type;
import info.archinnov.achilles.generated.function.PartitionKeys_Type;
import info.archinnov.achilles.generated.function.String_Type;
import info.archinnov.achilles.generated.function.UUID_Type;
import info.archinnov.achilles.generated.meta.entity.TestEntityWithCompositePartitionKey_AchillesMeta.ColumnsForFunctions;
import info.archinnov.achilles.internals.apt.annotations.AchillesMeta;
import info.archinnov.achilles.internals.codec.FallThroughCodec;
import info.archinnov.achilles.internals.metamodel.AbstractEntityProperty;
import info.archinnov.achilles.internals.metamodel.AbstractProperty;
import info.archinnov.achilles.internals.metamodel.SimpleProperty;
import info.archinnov.achilles.internals.metamodel.columns.ColumnInfo;
import info.archinnov.achilles.internals.metamodel.columns.ColumnType;
import info.archinnov.achilles.internals.metamodel.columns.FieldInfo;
import info.archinnov.achilles.internals.metamodel.columns.PartitionKeyInfo;
import info.archinnov.achilles.internals.metamodel.index.IndexInfo;
import info.archinnov.achilles.internals.sample_classes.parser.entity.TestEntityWithCompositePartitionKey;
import info.archinnov.achilles.internals.strategy.naming.InternalNamingStrategy;
import info.archinnov.achilles.type.strategy.InsertStrategy;
import java.lang.Class;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.lang.UnsupportedOperationException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
 * Meta class of all entities of type TestEntityWithCompositePartitionKey<br/>
 * The meta class is responsible for<br/>
 * <ul>
 *    <li>determining runtime consistency levels (read/write,serial)<li/>
 *    <li>determining runtime insert strategy<li/>
 *    <li>trigger event interceptors (if any)<li/>
 *    <li>map a Row back to an instance of TestEntityWithCompositePartitionKey<li/>
 *    <li>determine runtime keyspace name using static annotations and runtime SchemaNameProvider (if any)<li/>
 *    <li>determine runtime table name using static annotations and runtime SchemaNameProvider (if any)<li/>
 *    <li>generate schema during bootstrap<li/>
 *    <li>validate schema during bootstrap<li/>
 *    <li>expose all property meta classes for encoding/decoding purpose on unitary columns<li/>
 * <ul/>
 */
@AchillesMeta
public final class TestEntityWithCompositePartitionKey_AchillesMeta extends AbstractEntityProperty<TestEntityWithCompositePartitionKey> {
  /**
   * Meta class for 'id' property <br/>
   * The meta class exposes some useful methods: <ul>
   *    <li>encodeFromJava: encode a property from raw Java to CQL java compatible type </li>
   *    <li>encodeField: extract the current property value from the given TestEntityWithCompositePartitionKey instance and encode to CQL java compatible type </li>
   *    <li>decodeFromGettable: decode from a {@link com.datastax.driver.core.GettableData} instance (Row, UDTValue, TupleValue) the current property</li>
   * </ul>
   */
  @SuppressWarnings({"serial", "unchecked"})
  public static final SimpleProperty<TestEntityWithCompositePartitionKey, Long, Long> id = new SimpleProperty<TestEntityWithCompositePartitionKey, Long, Long>(new FieldInfo<>((TestEntityWithCompositePartitionKey entity$) -> entity$.getId(), (TestEntityWithCompositePartitionKey entity$, Long value$) -> entity$.setId(value$), "id", "id", ColumnType.PARTITION, new PartitionKeyInfo(1, false), IndexInfo.noIndex()), DataType.bigint(), gettableData$ -> gettableData$.get("id", java.lang.Long.class), (settableData$, value$) -> settableData$.set("id", value$, java.lang.Long.class), new TypeToken<Long>(){}, new TypeToken<Long>(){}, new FallThroughCodec<>(Long.class));

  /**
   * Meta class for 'uuid' property <br/>
   * The meta class exposes some useful methods: <ul>
   *    <li>encodeFromJava: encode a property from raw Java to CQL java compatible type </li>
   *    <li>encodeField: extract the current property value from the given TestEntityWithCompositePartitionKey instance and encode to CQL java compatible type </li>
   *    <li>decodeFromGettable: decode from a {@link com.datastax.driver.core.GettableData} instance (Row, UDTValue, TupleValue) the current property</li>
   * </ul>
   */
  @SuppressWarnings({"serial", "unchecked"})
  public static final SimpleProperty<TestEntityWithCompositePartitionKey, UUID, UUID> uuid = new SimpleProperty<TestEntityWithCompositePartitionKey, UUID, UUID>(new FieldInfo<>((TestEntityWithCompositePartitionKey entity$) -> entity$.getUuid(), (TestEntityWithCompositePartitionKey entity$, UUID value$) -> entity$.setUuid(value$), "uuid", "uuid", ColumnType.PARTITION, new PartitionKeyInfo(2, false), IndexInfo.noIndex()), DataType.uuid(), gettableData$ -> gettableData$.get("uuid", java.util.UUID.class), (settableData$, value$) -> settableData$.set("uuid", value$, java.util.UUID.class), new TypeToken<UUID>(){}, new TypeToken<UUID>(){}, new FallThroughCodec<>(UUID.class));

  /**
   * Meta class for 'value' property <br/>
   * The meta class exposes some useful methods: <ul>
   *    <li>encodeFromJava: encode a property from raw Java to CQL java compatible type </li>
   *    <li>encodeField: extract the current property value from the given TestEntityWithCompositePartitionKey instance and encode to CQL java compatible type </li>
   *    <li>decodeFromGettable: decode from a {@link com.datastax.driver.core.GettableData} instance (Row, UDTValue, TupleValue) the current property</li>
   * </ul>
   */
  @SuppressWarnings({"serial", "unchecked"})
  public static final SimpleProperty<TestEntityWithCompositePartitionKey, String, String> value = new SimpleProperty<TestEntityWithCompositePartitionKey, String, String>(new FieldInfo<>((TestEntityWithCompositePartitionKey entity$) -> entity$.getValue(), (TestEntityWithCompositePartitionKey entity$, String value$) -> entity$.setValue(value$), "value", "value", ColumnType.NORMAL, new ColumnInfo(false), IndexInfo.noIndex()), DataType.text(), gettableData$ -> gettableData$.get("value", java.lang.String.class), (settableData$, value$) -> settableData$.set("value", value$, java.lang.String.class), new TypeToken<String>(){}, new TypeToken<String>(){}, new FallThroughCodec<>(String.class));

  /**
   * Static class to expose "TestEntityWithCompositePartitionKey_AchillesMeta" fields for <strong>type-safe</strong> function calls */
  public static final TestEntityWithCompositePartitionKey_AchillesMeta.ColumnsForFunctions COLUMNS = new TestEntityWithCompositePartitionKey_AchillesMeta.ColumnsForFunctions();
  ;

  @Override
  protected Class<TestEntityWithCompositePartitionKey> getEntityClass() {
    return TestEntityWithCompositePartitionKey.class;
  }

  @Override
  protected String getDerivedTableOrViewName() {
    return "testentitywithcompositepartitionkey";
  }

  @Override
  protected BiMap<String, String> fieldNameToCqlColumn() {
    BiMap<String,String> map = HashBiMap.create(3);
    map.put("id", "id");
    map.put("uuid", "uuid");
    map.put("value", "value");
    return map;
  }

  @Override
  protected Optional<ConsistencyLevel> getStaticReadConsistency() {
    return Optional.empty();
  }

  @Override
  protected Optional<InternalNamingStrategy> getStaticNamingStrategy() {
    return Optional.empty();
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getPartitionKeys() {
    return Arrays.asList(id,uuid);
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getClusteringColumns() {
    return Arrays.asList();
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getNormalColumns() {
    return Arrays.asList(value);
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getComputedColumns() {
    return Arrays.asList();
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getConstructorInjectedColumns() {
    return Arrays.asList();
  }

  @Override
  protected boolean isCounterTable() {
    return false;
  }

  @Override
  protected Optional<String> getStaticKeyspace() {
    return Optional.empty();
  }

  @Override
  protected Optional<String> getStaticTableOrViewName() {
    return Optional.empty();
  }

  @Override
  protected Optional<ConsistencyLevel> getStaticWriteConsistency() {
    return Optional.empty();
  }

  @Override
  protected Optional<ConsistencyLevel> getStaticSerialConsistency() {
    return Optional.empty();
  }

  @Override
  protected Optional<Integer> getStaticTTL() {
    return Optional.empty();
  }

  @Override
  protected Optional<InsertStrategy> getStaticInsertStrategy() {
    return Optional.empty();
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getStaticColumns() {
    return Arrays.asList();
  }

  @Override
  protected List<AbstractProperty<TestEntityWithCompositePartitionKey, ?, ?>> getCounterColumns() {
    return Arrays.asList();
  }

  @Override
  protected TestEntityWithCompositePartitionKey newInstanceFromCustomConstructor(final Row row, final List<String> cqlColumns) {
    throw new UnsupportedOperationException("Cannot instantiate entity 'info.archinnov.achilles.internals.sample_classes.parser.entity.TestEntityWithCompositePartitionKey' using custom constructor because no custom constructor (@EntityCreator) is defined");
  }

  /**
   * Utility class to expose all fields with their CQL type for function call */
  public static final class ColumnsForFunctions {
    /**
     * <br/>
     * Field to be used for <em>manager.dsl().select().function(...)</em> call
     * <br/>
     * This is an alias for the field <strong>"id"</strong> */
    public final Long_Type ID = new Long_Type(Optional.empty()){
      @Override
      protected String cqlColumn() {
          return "id";
    }
      @Override
      public boolean isFunctionCall() {
          return false;
    }
      }
    ;

    /**
     * <br/>
     * Field to be used for <em>manager.dsl().select().function(...)</em> call
     * <br/>
     * This is an alias for the field <strong>"uuid"</strong> */
    public final UUID_Type UUID = new UUID_Type(Optional.empty()){
      @Override
      protected String cqlColumn() {
          return "uuid";
    }
      @Override
      public boolean isFunctionCall() {
          return false;
    }
      }
    ;

    /**
     * <br/>
     * Field to be used for <em>manager.dsl().select().function(...)</em> call
     * <br/>
     * This is an alias for the field <strong>"value"</strong> */
    public final String_Type VALUE = new String_Type(Optional.empty()){
      @Override
      protected String cqlColumn() {
          return "value";
    }
      @Override
      public boolean isFunctionCall() {
          return false;
    }
      }
    ;

    /**
     * <br/>
     * Field to be used with <em>SystemFunctions.token(xxx_AchillesMeta.COLUMNS.PARTITION_KEYS, "tokens")</em> call
     * <br/>
     */
    public final PartitionKeys_Type PARTITION_KEYS = new PartitionKeys_Type(new ArrayList<String>() {
     {
     add("id"); add("uuid"); }
      })
    ;
  }
}