Example usage for org.apache.commons.collections15 AbstractExtendedClosure AbstractExtendedClosure

List of usage examples for org.apache.commons.collections15 AbstractExtendedClosure AbstractExtendedClosure

Introduction

In this page you can find the example usage for org.apache.commons.collections15 AbstractExtendedClosure AbstractExtendedClosure.

Prototype

protected AbstractExtendedClosure(Class<T> argType) 

Source Link

Usage

From source file:org.springframework.jdbc.repo.impl.AbstractIdentifiedEntityRepo.java

@Override
public List<E> findEntities(Collection<String> idsList) {
    if (ExtendedCollectionUtils.isEmpty(idsList)) {
        return Collections.emptyList();
    }//from  ww w  .ja  v a  2s.  c  om

    final List<E> result = new ArrayList<E>(idsList.size());
    Set<String> idSet = (idsList instanceof Set) ? (Set<String>) idsList : new LinkedHashSet<>(idsList);
    CollectionUtils.forAllDo(idSet, new AbstractExtendedClosure<String>(String.class) {
        @Override
        public void execute(String id) {
            if (StringUtils.isEmpty(id)) {
                return;
            }

            E entity = findEntityById(id);
            if (entity == null) {
                return;
            }

            result.add(entity);
        }
    });
    return result;
}

From source file:org.springframework.jdbc.repo.impl.AbstractIdentifiedEntityRepo.java

@Override
public List<E> removeAll(Collection<String> idsList) {
    if (ExtendedCollectionUtils.isEmpty(idsList)) {
        return Collections.emptyList();
    }//from w  w  w .  j av  a 2 s.co  m

    final List<E> result = new ArrayList<E>(idsList.size());
    CollectionUtils.forAllDo(idsList, new AbstractExtendedClosure<String>(String.class) {
        @Override
        public void execute(String id) {
            if (StringUtils.isEmpty(id)) {
                return;
            }

            E entity = removeEntity(id);
            if (entity == null) {
                return;
            }

            result.add(entity);
        }
    });
    return result;
}