Is there anything bad in declaring static inner class inside interface in java?
        Posted  
        
            by Roman
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Roman
        
        
        
        Published on 2010-05-24T10:28:49Z
        Indexed on 
            2010/05/24
            10:31 UTC
        
        
        Read the original article
        Hit count: 301
        
I have an interface ProductService with method findByCriteria. This method had a long list of nullable parameters, like productName, maxCost, minCost, producer and so on.
I refactored this method by introducing Parameter Object. I created class SearchCriteria and now method signature looks like this:
findByCriteria (SearchCriteria criteria)
I thought that instances of SearchCriteria are only created by method callers and are only used inside findByCriteria method, i.e.:
void processRequest() {
   SearchCriteria criteria = new SearchCriteria ()
                                  .withMaxCost (maxCost)
                                  .......
                                  .withProducer (producer);
   List<Product> products = productService.findByCriteria (criteria);
   ....
}
and
List<Product> findByCriteria(SearchCriteria criteria) {
    return doSmthAndReturnResult(criteria.getMaxCost(), criteria.getProducer());    
}
So I did not want to create separate public class for SearchCriteria and put it inside ProductServiceInterface:
public interface ProductService {
    List<Product> findByCriteria (SearchCriteria criteria);
    static class SearchCriteria {
       ...
    }
}
Is there anything bad in this interface? Where whould you place SearchCriteria class?
© Stack Overflow or respective owner