org.apache.ignite.cache.store.cassandra.persistence

## Class PojoField

- java.lang.Object
- - org.apache.ignite.cache.store.cassandra.persistence.PojoField

- All Implemented Interfaces:
    Serializable
  Direct Known Subclasses:
    PojoKeyField, PojoValueField

      public abstract class PojoField
      extends Object
      implements Serializable

  Descriptor for particular field in a POJO object, specifying how this field should be written to or loaded from Cassandra.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PojoField(Element el, Class<?> pojoCls)` Creates instance of `PojoField` based on it's description in XML element.
    `PojoField(PojoFieldAccessor accessor)` Creates instance of `PojoField` from its field accessor.
    `PojoField(PojoField field, Class<?> pojoCls)` Creates instance of `PojoField` from the other instance and java class.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `calculatedField()` Indicates if it's a calculated field - field which value just generated based on other field values.
    `static boolean` | `containsField(List<? extends PojoField> fields, String fieldName)` Checks if list contains POJO field with the specified name.
    `Annotation` | `getAnnotation(Class clazz)` Returns POJO field annotation.
    `String` | `getColumn()`
    `String` | `getColumnDDL()`
    `Class` | `getJavaClass()` Returns java class of the field.
    `String` | `getName()`
    `Object` | `getValueFromObject(Object obj, Serializer serializer)` Gets field value as an object having Cassandra compatible type.
    `void` | `setValueFromRow(com.datastax.driver.core.Row row, Object obj, Serializer serializer)` Sets object field value from a `Row` returned by Cassandra CQL statement.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PojoField

          public PojoField(Element el,
                           Class<?> pojoCls)

      Creates instance of `PojoField` based on it's description in XML element.
      Parameters:
        `el` - XML element describing Pojo field
        `pojoCls` - Pojo java class.

    - #### PojoField

          public PojoField(PojoFieldAccessor accessor)

      Creates instance of `PojoField` from its field accessor.
      Parameters:
        `accessor` - field accessor.

    - #### PojoField

          public PojoField(PojoField field,
                           Class<?> pojoCls)

      Creates instance of `PojoField` from the other instance and java class.

  - ### Method Detail

    - #### containsField

          public static boolean containsField(List<? extends PojoField> fields,
                                              String fieldName)

      Checks if list contains POJO field with the specified name.
      Parameters:
        `fields` - list of POJO fields.
        `fieldName` - field name.
      Returns:
        true if list contains field or false otherwise.

    - #### getName

          public String getName()

      Returns:
        field name.

    - #### getJavaClass

          public Class getJavaClass()

      Returns java class of the field.
      Returns:
        Java class.

    - #### getColumn

          public String getColumn()

      Returns:
        Cassandra table column name.

    - #### getColumnDDL

          public String getColumnDDL()

      Returns:
        Cassandra table column DDL statement.

    - #### calculatedField

          public boolean calculatedField()

      Indicates if it's a calculated field - field which value just generated based on other field values. Such field will be stored in Cassandra as all other POJO fields, but it's value shouldn't be read from Cassandra - cause it's again just generated based on other field values. One of the good applications of such kind of fields - Cassandra materialized views build on top of other tables.
      Returns:
        `true` if it's auto generated field, `false` if not.

    - #### getValueFromObject

          public Object getValueFromObject(Object obj,
                                           Serializer serializer)

      Gets field value as an object having Cassandra compatible type. This it could be stored directly into Cassandra without any conversions.
      Parameters:
        `obj` - Object instance.
        `serializer` - `Serializer` to use.
      Returns:
        Object to store in Cassandra table column.

    - #### getAnnotation

          public Annotation getAnnotation(Class clazz)

      Returns POJO field annotation.
      Returns:
        annotation.

    - #### setValueFromRow

          public void setValueFromRow(com.datastax.driver.core.Row row,
                                      Object obj,
                                      Serializer serializer)

      Sets object field value from a `Row` returned by Cassandra CQL statement.
      Parameters:
        `row` - `Row`
        `obj` - object which field should be populated from `Row`
        `serializer` - `Serializer` to use.

2020 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020