com.h3c.util.persistence.cassandra.entitymgr.column

## Class CustomColumn<C extends Serializable & Comparable<C>,D>

- java.lang.Object
- - com.h3c.util.persistence.cassandra.entitymgr.column.Column<C,D>
  - - com.h3c.util.persistence.cassandra.entitymgr.column.CustomColumn<C,D>

- Type Parameters:
    `C` - type of the column name or column key
    `D` - type of the column value
  All Implemented Interfaces:
    Visitable<ColumnVisitor<C>>

      public class CustomColumn<C extends Serializable & Comparable<C>,D>
      extends Column<C,D>

  Custom column.

  A custom column is normally used to create a composite column which is normally used to implement filtering with a secondary index. For example, to filter persons by Status and Sex ("Get all female single persons") a composite column that stores the status and sex can be created and a secondary index can be set. Thus the column family to store persons would have a column for status ( to support filtering by status), a column for sex (to support filtering by sex) and a composite column for status-sex.

  A composite column is also used to implement super columns. Astyanax deprecated `ColumnPath` with the following comment: "Super columns should be replaced with composite columns". All super columns support was dropped in favor of composite columns. Cassandra will eventually replace the super column implementation with composite columns.

  Note that composite columns that will act as super columns are nornally not indexed since they will tend to store several values.

  Note: In order to use the value of a custom column, when it is read from the column family, it will have to be casted.

       Column<C, ?> column = read(...);
       SomeObj someObj =  (SomeObj)column.getValue();

  For specific applications that use specific custom values an additional visitor pattern may be used to avoid casting. For each subclass of `CustomColumn` a `ColumnDecoder` will have to be created too to create the right subclass instance. However the same `CustomColumn.CustomIndexValueExpressionStrategy` can be used.

  Example:

       public abstract class MyCustomColumn<C extends Serializable &
               Comparable<C>, D> extends CustomColumn<C, D> {
           ...
           public abstract void accept(MyCustomColumnVisitor<C> visitor);
       }

       public class SomeObjColumn<C extends Serializable & Comparable<C>
       >extends MyCustomColumn<C, SomeObj> {
           ...
           @Override
           public void accept(MyCustomColumnVisitor<C> visitor) {
               visitor.visit(this);
           }
       }

       public interface MyCustomColumnVisitor<C extends Serializable &
               Comparable<C>> {
           public void visit(SomeObjColumn<C> column);
       }

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CustomColumn.CustomColumnDecoder<C extends Serializable & Comparable<C>,D>` Custom column decoder.
    `static class` | `CustomColumn.CustomIndexValueExpressionStrategy<K extends Serializable,C extends Serializable & Comparable<C>,D>` Custom index value expression strategy.

  - ### Field Summary

    - ### Fields inherited from class com.h3c.util.persistence.cassandra.entitymgr.column.Column

      `serializer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CustomColumn(ColumnName<C,D> name)` Creates a boolean column with no value
    `CustomColumn(ColumnName<C,D> name, D value, com.netflix.astyanax.Serializer<D> serializer)` Creates a boolean column.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `accept(ColumnVisitor<C> visitor)` Calls a visit method of the visitor, this class object passes itself as an argument to the visit method this class object.
    `void` | `addToMutation(com.netflix.astyanax.ColumnListMutation<C> mutation)` Adds the column to a mutation.
    `com.netflix.astyanax.Execution<Void>` | `addToMutation(com.netflix.astyanax.ColumnMutation mutation)` Adds the column to a mutation.
    `int` | `compareTo(Column<C,D> o2)`

    - ### Methods inherited from class com.h3c.util.persistence.cassandra.entitymgr.column.Column

      `equals, getName, getSerializer, getValue, hashCode, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CustomColumn

          public CustomColumn(ColumnName<C,D> name)

      Creates a boolean column with no value
      Parameters:
        `name` - column's name

    - #### CustomColumn

          public CustomColumn(ColumnName<C,D> name,
                      D value,
                      com.netflix.astyanax.Serializer<D> serializer)

      Creates a boolean column.
      Parameters:
        `name` - column's name
        `value` - column's value
        `serializer` - serializer

  - ### Method Detail

    - #### compareTo

          public int compareTo(Column<C,D> o2)

      Specified by:
        `compareTo` in class `Column<C extends Serializable & Comparable<C>,D>`

    - #### accept

          public void accept(ColumnVisitor<C> visitor)

      Calls a visit method of the visitor, this class object passes itself as an argument to the visit method this class object.
      Parameters:
        `visitor` - ColumnVisitor

    - #### addToMutation

          public com.netflix.astyanax.Execution<Void> addToMutation(com.netflix.astyanax.ColumnMutation mutation)

      Adds the column to a mutation.
      Parameters:
        `mutation` - to add the column to
      Returns:
        execution

    - #### addToMutation

          public void addToMutation(com.netflix.astyanax.ColumnListMutation<C> mutation)

      Adds the column to a mutation.
      Parameters:
        `mutation` - to add the column to

Copyright © 2014. All Rights Reserved.