org.ujorm.orm.ao
Class IndexModelOrderedBuilder

java.lang.Object
  extended by org.ujorm.orm.ao.IndexModelBuilder
      extended by org.ujorm.orm.ao.IndexModelOrderedBuilder

public class IndexModelOrderedBuilder
extends IndexModelBuilder

Database meta index model builder with a user ordered columns support. Two columns of a database composite index can be ordered according a number at the end of a index name separated by the character '#'. Two index columns with the same order value are sorted according to the natural order of the Keys in the Ujo class. The default order value (with no number in the index name) is 10.
See the next example to create a composite index with two columns in a reverted order:

   @Column(index = IDX_STATE_NOTE + "#30")
   public static final Key<XOrder, State> STATE = newKey();

   @Column(index = IDX_STATE_NOTE + "#20")
   public static final Key<XOrder, Integer> COUNT = newKey();
 
The builder class can be changed by the parameter MetaParams.INDEX_MODEL_BUILDER.

See Also:
MetaParams.INDEX_MODEL_BUILDER

Nested Class Summary
protected static class IndexModelOrderedBuilder.OrderedColumn
          Container for the Index model with an order request
 
Field Summary
protected static Integer DEFAULT_ORDER
          The default index column value is 10
 
Fields inherited from class org.ujorm.orm.ao.IndexModelBuilder
mapIndex, metaTable, nameProvider
 
Constructor Summary
IndexModelOrderedBuilder()
           
 
Method Summary
protected  void addIndex(String indexName, MetaColumn column, boolean unique)
          Add the column model to the column model from the IndexMap according the column name (case insensitive)
protected  void addToResult(List<IndexModelOrderedBuilder.OrderedColumn> columns, boolean unique, List<MetaIndex> result)
          Add the column to the result index list
 Collection<MetaIndex> getIndexModels()
          Returns all indexes of the current table
protected  char getOrderSerparator()
          Returns a separator of the column order from an index name.
 
Methods inherited from class org.ujorm.orm.ao.IndexModelBuilder
addColumnsToIndex, init, isExtendedIndexStrategy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ORDER

protected static final Integer DEFAULT_ORDER
The default index column value is 10

Constructor Detail

IndexModelOrderedBuilder

public IndexModelOrderedBuilder()
Method Detail

getOrderSerparator

protected char getOrderSerparator()
Returns a separator of the column order from an index name.

Returns:
The default value is '#'
See Also:
DEFAULT_ORDER

addIndex

protected void addIndex(String indexName,
                        MetaColumn column,
                        boolean unique)
Add the column model to the column model from the IndexMap according the column name (case insensitive)

Overrides:
addIndex in class IndexModelBuilder
Parameters:
indexName - Case sensitive column name
column - Column model
unique - Unique column request

getIndexModels

public Collection<MetaIndex> getIndexModels()
Returns all indexes of the current table

Overrides:
getIndexModels in class IndexModelBuilder
Returns:
Collection of the Index model

addToResult

protected void addToResult(List<IndexModelOrderedBuilder.OrderedColumn> columns,
                           boolean unique,
                           List<MetaIndex> result)
Add the column to the result index list



Copyright 2013, Pavel Ponec