class HostConfigMappingDAO {

  @RequiresSession
  public HostConfigMapping findSelectedByType(final long clusterId,
      Long hostId, final String type) {
    populateCache();
    
    if (!hostConfigMappingByHost.containsKey(hostId))
      return null;
    
    Set<HostConfigMapping> set = new HashSet<>(hostConfigMappingByHost.get(hostId));
    
    HostConfigMapping result = (HostConfigMapping) CollectionUtils.find(set, new Predicate() {
      
      @Override
      public boolean evaluate(Object arg0) {
        return ((HostConfigMapping) arg0).getClusterId().equals(clusterId) 
            && ((HostConfigMapping) arg0).getType().equals(type)
            && ((HostConfigMapping) arg0).getSelected() > 0;
      }
    });
    
    return result;
  }

}