final Collection<Map<String,Object>> numericFields = property.getNumericFields();
List<org.hibernate.search.annotations.Field> fieldAnnotations =
new ArrayList<org.hibernate.search.annotations.Field>( fields.size() );
List<NumericField> numericFieldAnnotations = new ArrayList<NumericField>( numericFields.size() );
for(Map<String, Object> numericField : numericFields) {
AnnotationDescriptor fieldAnnotation = new AnnotationDescriptor( NumericField.class );
for ( Map.Entry<String, Object> entry : numericField.entrySet() ) {
fieldAnnotation.setValue( entry.getKey(), entry.getValue() );
}
numericFieldAnnotations.add( (NumericField) AnnotationFactory.create( fieldAnnotation ) );
}
for(Map<String, Object> field : fields) {
AnnotationDescriptor fieldAnnotation = new AnnotationDescriptor( org.hibernate.search.annotations.Field.class );
for ( Map.Entry<String, Object> entry : field.entrySet() ) {
if ( entry.getKey().equals( "analyzer" ) ) {
AnnotationDescriptor analyzerAnnotation = new AnnotationDescriptor( Analyzer.class );
@SuppressWarnings("unchecked")
Map<String, Object> analyzer = (Map<String, Object>) entry.getValue();
for ( Map.Entry<String, Object> analyzerEntry : analyzer.entrySet() ) {
analyzerAnnotation.setValue( analyzerEntry.getKey(), analyzerEntry.getValue() );
}
fieldAnnotation.setValue( "analyzer", AnnotationFactory.create( analyzerAnnotation ) );
}
else if ( entry.getKey().equals( "boost" ) ) {
AnnotationDescriptor boostAnnotation = new AnnotationDescriptor( Boost.class );
@SuppressWarnings("unchecked")
Map<String, Object> boost = (Map<String, Object>) entry.getValue();
for ( Map.Entry<String, Object> boostEntry : boost.entrySet() ) {
boostAnnotation.setValue( boostEntry.getKey(), boostEntry.getValue() );
}
fieldAnnotation.setValue( "boost", AnnotationFactory.create( boostAnnotation ) );
}
else if ( entry.getKey().equals( "bridge" ) ) {
AnnotationDescriptor bridgeAnnotation = new AnnotationDescriptor( FieldBridge.class );
@SuppressWarnings("unchecked")
Map<String, Object> bridge = (Map<String, Object>) entry.getValue();
for ( Map.Entry<String, Object> bridgeEntry : bridge.entrySet() ) {
if ( bridgeEntry.getKey().equals( "params" ) ) {
addParamsToAnnotation( bridgeAnnotation, bridgeEntry );
}
else {
bridgeAnnotation.setValue( bridgeEntry.getKey(), bridgeEntry.getValue() );
}
}
fieldAnnotation.setValue( "bridge", AnnotationFactory.create( bridgeAnnotation ) );
}
else {
fieldAnnotation.setValue( entry.getKey(), entry.getValue() );
}
}
fieldAnnotations.add( (org.hibernate.search.annotations.Field) AnnotationFactory.create( fieldAnnotation ) );
}
AnnotationDescriptor fieldsAnnotation = new AnnotationDescriptor( Fields.class );
AnnotationDescriptor numericFieldsAnnotation = new AnnotationDescriptor( NumericFields.class );
final org.hibernate.search.annotations.Field[] fieldArray =
new org.hibernate.search.annotations.Field[fieldAnnotations.size()];
final org.hibernate.search.annotations.Field[] fieldAsArray = fieldAnnotations.toArray( fieldArray );
final NumericField[] numericFieldArray = new NumericField[numericFieldAnnotations.size()];
final NumericField[] numericFieldAsArray = numericFieldAnnotations.toArray( numericFieldArray );
numericFieldsAnnotation.setValue( "value", numericFieldAsArray);
annotations.put( NumericFields.class, AnnotationFactory.create( numericFieldsAnnotation ));
fieldsAnnotation.setValue( "value", fieldAsArray );
annotations.put( Fields.class, AnnotationFactory.create( fieldsAnnotation ) );
createDateBridge( property );
createCalendarBridge( property );