bindFullTextFilterDef( defAnn );
}
private void bindFullTextFilterDef(FullTextFilterDef defAnn) {
FilterDef filterDef = new FilterDef( defAnn );
final Map<String, FilterDef> filterDefinition = factoryState.getFilterDefinitions();
if ( filterDef.getImpl().equals( ShardSensitiveOnlyFilter.class ) ) {
//this is a placeholder don't process regularly
filterDefinition.put( defAnn.name(), filterDef );
return;
}
try {
filterDef.getImpl().newInstance();
}
catch ( IllegalAccessException e ) {
throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
}
catch ( InstantiationException e ) {
throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
}
for ( Method method : filterDef.getImpl().getMethods() ) {
if ( method.isAnnotationPresent( Factory.class ) ) {
if ( filterDef.getFactoryMethod() != null ) {
throw new SearchException(
"Multiple @Factory methods found" + defAnn.name() + ": "
+ filterDef.getImpl().getName() + "." + method.getName()
);
}
ReflectionHelper.setAccessible( method );
filterDef.setFactoryMethod( method );
}
if ( method.isAnnotationPresent( Key.class ) ) {
if ( filterDef.getKeyMethod() != null ) {
throw new SearchException(
"Multiple @Key methods found" + defAnn.name() + ": "
+ filterDef.getImpl().getName() + "." + method.getName()
);
}
ReflectionHelper.setAccessible( method );
filterDef.setKeyMethod( method );
}
String name = method.getName();
if ( name.startsWith( "set" ) && method.getParameterTypes().length == 1 ) {
filterDef.addSetter( Introspector.decapitalize( name.substring( 3 ) ), method );
}
}
filterDefinition.put( defAnn.name(), filterDef );
}