Example usage for org.apache.commons.collections IteratorUtils toList

List of usage examples for org.apache.commons.collections IteratorUtils toList

Introduction

In this page you can find the example usage for org.apache.commons.collections IteratorUtils toList.

Prototype

public static List toList(Iterator iterator) 

Source Link

Document

Gets a list based on an iterator.

Usage

From source file:gda.gui.text.TextArea.ThreadSafeRingBuffer.java

public synchronized List<E> getContent() {
    Iterator<?> it = buffer.iterator();
    @SuppressWarnings("unchecked")
    List<E> items = IteratorUtils.toList(it);
    return items;
}

From source file:demo.controllers.TestController.java

@RequestMapping(value = "/customers/all")
List<Customer> getAll() {/*from   w  w  w.  j  a v  a2s . c  om*/
    Iterable<Customer> it = repository.findAll();
    if (it != null) {
        return IteratorUtils.toList(it.iterator());
    } else {
        return new ArrayList<>();
    }
}

From source file:com.br.helpdesk.service.ChangesTicketService.java

public List<ChangesTicket> findAll() {
    return IteratorUtils.toList(repository.findAll().iterator());
}

From source file:it.inserpio.neo4art.service.impl.MuseumEntityService.java

@Override
@Transactional/*from  w  w  w . j a  va 2s  .co m*/
@SuppressWarnings("unchecked")
public List<Museum> getMuseumsWithinDistance(double longitude, double latitude, double distanceInKm) {
    return IteratorUtils.toList(this.museumRepository
            .findWithinDistance(MuseumRepository.MUSEUM_GEOSPATIAL_INDEX, longitude, latitude, distanceInKm)
            .iterator());
}

From source file:ec.edu.espe.distribuidas.factnosql.servicios.PersonaServicio.java

public List<PersonasSum> sumarizadoPersonas() {
    Iterator<PersonasSum> aggregate = persistence.context().createAggregation(Factura.class).group("persona",
            Group.grouping("count", new Accumulator("$sum", 1)), Group.grouping("cedula", Group.first("valor")))
            .aggregate(PersonasSum.class);
    List<PersonasSum> presonasS = IteratorUtils.toList(aggregate);
    for (PersonasSum p : presonasS)
        System.out.println(p);/*from  w  w w . j av a2  s  .c o  m*/
    Query q = persistence.context().createQuery(Persona.class);
    List<Persona> personas = q.asList();

    for (Persona p : personas) {
        boolean flag = true;
        for (int i = 0; i < presonasS.size(); i++) {
            if (p.getCedula().equals(presonasS.get(i).getCedula())) {
                flag = false;
                presonasS.get(i).setPersona(p);
            }
        }
        if (flag)
            presonasS.add(new PersonasSum(p, 0, p.getCedula()));
    }

    return presonasS;
}

From source file:com.br.helpdesk.service.ChangesTicketService.java

public List<ChangesTicket> findByUser(User user) {
    return IteratorUtils.toList(repository.findByUser(user).iterator());
}

From source file:com.activecq.samples.resourcewrappers.impl.SampleSlideshowResourceWrapper.java

/**
 * Get the number of child nodes. It is expected all child nodes are Image nodes.
 * <p/>//w  w w  .j a v  a  2s. com
 * A real implementation can check child nodes for appropriate resourceTypes, etc. qualifying each resource as valid Image resource.
 *
 * @return
 */
public int getSize() {
    List<Resource> children = IteratorUtils.toList(this.resource.listChildren());
    if (children == null) {
        return 0;
    }
    return children.size();
}

From source file:com.br.helpdesk.service.ChangesTicketService.java

public List<ChangesTicket> findByTicket(Ticket ticket) {
    return IteratorUtils.toList(repository.findByTicket(ticket).iterator());
}

From source file:com.activecq.api.utils.TypeUtil.java

/**
 * Converts a JSONObject to a simple Map. This will only work properly for
 * JSONObjects of depth 1.//w w  w . j  av  a2  s.  c  o  m
 *
 * @param json
 * @return
 */
public static Map toMap(JSONObject json) {
    HashMap<String, Object> map = new HashMap<String, Object>();
    List<String> keys = IteratorUtils.toList(json.keys());

    for (String key : keys) {
        try {
            map.put(key, json.get(key));
        } catch (JSONException ex) {
            Logger.getLogger(ActiveForm.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    return map;
}

From source file:com.splicemachine.derby.stream.function.CogroupAntiJoinRestrictionFlatMapFunction.java

@Override
public Iterator<LocatedRow> call(Tuple2<Iterable<LocatedRow>, Iterable<LocatedRow>> tuple) throws Exception {
    checkInit();/*from   w w  w  .j av a  2  s  . co m*/
    Iterable<LocatedRow> rightSide = tuple._2;
    List<Iterable<LocatedRow>> returnRows = new LinkedList<>();
    for (LocatedRow a_1 : tuple._1) {
        returnRows.add(
                IteratorUtils.toList(antiJoinRestrictionFlatMapFunction.call(new Tuple2<>(a_1, rightSide))));
    }
    return new ConcatenatedIterable<>(returnRows).iterator();
}