private void onCollectionColumns ( CQLTranslator translator , List < CollectionColumnInfo > collectionColumnInfos , StringBuilder queryBuilder ) { for ( CollectionColumnInfo cci : collectionColumnInfos ) { String dataType = CassandraValidationClassMapper . getValidationClass ( cci . getType ( ) , true ) ; // CQL Type of collection column String collectionCqlType = translator . getCQLType ( dataType ) ; // Collection Column Name String collectionColumnName = new String ( cci . getCollectionColumnName ( ) ) ; // Generic Type list StringBuilder genericTypesBuilder = null ; List < Class < ? > > genericClasses = cci . getGenericClasses ( ) ; if ( ! genericClasses . isEmpty ( ) ) { genericTypesBuilder = new StringBuilder ( ) ; if ( MapType . class . getSimpleName ( ) . equals ( dataType ) && genericClasses . size ( ) == 2 ) { genericTypesBuilder . append ( Constants . STR_LT ) ; String keyDataType = CassandraValidationClassMapper . getValidationClass ( genericClasses . get ( 0 ) , true ) ; genericTypesBuilder . append ( translator . getCQLType ( keyDataType ) ) ; genericTypesBuilder . append ( Constants . SPACE_COMMA ) ; String valueDataType = CassandraValidationClassMapper . getValidationClass ( genericClasses . get ( 1 ) , true ) ; genericTypesBuilder . append ( translator . getCQLType ( valueDataType ) ) ; genericTypesBuilder . append ( Constants . STR_GT ) ; } else if ( ( ListType . class . getSimpleName ( ) . equals ( dataType ) || SetType . class . getSimpleName ( ) . equals ( dataType ) ) && genericClasses . size ( ) == 1 ) { genericTypesBuilder . append ( Constants . STR_LT ) ; String valueDataType = CassandraValidationClassMapper . getValidationClass ( genericClasses . get ( 0 ) , true ) ; genericTypesBuilder . append ( translator . getCQLType ( valueDataType ) ) ; genericTypesBuilder . append ( Constants . STR_GT ) ; } else { throw new SchemaGenerationException ( "Incorrect collection field definition for " + cci . getCollectionColumnName ( ) + ". Generic Types must be defined correctly." ) ; } } if ( genericTypesBuilder != null ) { collectionCqlType += genericTypesBuilder . toString ( ) ; } translator . appendColumnName ( queryBuilder , collectionColumnName , collectionCqlType ) ; queryBuilder . append ( Constants . SPACE_COMMA ) ; } }
Generates schema for Collection columns .