Example usage for java.util List indexOf

List of usage examples for java.util List indexOf

Introduction

In this page you can find the example usage for java.util List indexOf.

Prototype

int indexOf(Object o);

Source Link

Document

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

Usage

From source file:com.utest.dao.AuditTrailInterceptor.java

private void setValue(final Object[] currentState, final String[] propertyNames, final String propertyToSet,
        final Object value) {
    final List<String> names = Arrays.asList(propertyNames);
    final int index = names.indexOf(propertyToSet);
    if (index >= 0) {
        currentState[index] = value;/*from   w w  w  .j av  a  2s. c o m*/
    }
}

From source file:com.opengamma.analytics.math.curve.InterpolatedCurveShiftFunction.java

/**
 * {@inheritDoc}/*from   www  . j  a  v  a 2  s.  c o  m*/
 */
@Override
public InterpolatedDoublesCurve evaluate(final InterpolatedDoublesCurve curve, final double[] xShift,
        final double[] yShift, final String newName) {
    Validate.notNull(curve, "curve");
    Validate.notNull(xShift, "x shifts");
    Validate.notNull(yShift, "y shifts");
    Validate.isTrue(xShift.length == yShift.length);
    if (xShift.length == 0) {
        return InterpolatedDoublesCurve.from(curve.getXDataAsPrimitive(), curve.getYDataAsPrimitive(),
                curve.getInterpolator(), newName);
    }
    final List<Double> newX = new ArrayList<Double>(Arrays.asList(curve.getXData()));
    final List<Double> newY = new ArrayList<Double>(Arrays.asList(curve.getYData()));
    for (int i = 0; i < xShift.length; i++) {
        final int index = newX.indexOf(xShift[i]);
        if (index >= 0) {
            newY.set(index, newY.get(index) + yShift[i]);
        } else {
            newX.add(xShift[i]);
            newY.add(curve.getYValue(xShift[i]) + yShift[i]);
        }
    }
    return InterpolatedDoublesCurve.from(newX, newY, curve.getInterpolator(), newName);
}

From source file:cz.muni.fi.mir.scheduling.FormulaImportTask.java

/**
 * Method takes elements from formula and matches them against already
 * persisted list of elements. If element already exist then it has id in
 * obtained list (from database) and id for element in formula is set.
 * Otherwise we check temp list which contains newly created elements. If
 * there is no match then new element is created and stored in temp list.
 * Equals method somehow fails on CascadeType.ALL, so this is reason why we
 * have to do manually. TODO redo in future. Possible solution would be to
 * have all possible elements already stored inside database.
 *
 * @param f formula of which we attach elements.
 *//*www  . ja v a 2s .com*/
private void attachElements(Formula f) {
    if (f.getElements() != null && !f.getElements().isEmpty()) {
        List<Element> list = elementService.getAllElements();
        List<Element> newList = new ArrayList<>();
        for (Element e : f.getElements()) {
            int index = list.indexOf(e);
            if (index == -1) {
                int index2 = newList.indexOf(e);
                if (index2 == -1) {
                    elementService.createElement(e);
                    newList.add(e);
                } else {
                    e.setId(newList.get(index2).getId());
                }
            } else {
                e.setId(list.get(index).getId());
            }
        }
    }
}

From source file:com.ejisto.util.collector.FieldNode.java

public FieldNode fillGap(MockedField mockedField) {
    String[] missingPath = difference(path, mockedField.getComparisonKey()).split(MockedField.PATH_SEPARATOR);
    List<String> difference = asList(missingPath);

    final List<FieldNode> gap = Arrays.stream(missingPath).limit(Math.max(0, missingPath.length - 1))
            .filter(StringUtils::isNotBlank).map(p -> {
                int index = difference.indexOf(p);
                return difference.stream().limit(index + 1).collect(joining(MockedField.PATH_SEPARATOR));
            }).map(p -> new FieldNode(mockedField, p)).collect(Collectors.toList());
    gap.add(0, this);
    return gap.stream().reduce((f1, f2) -> {
        f1.addChild(f2);/*from w w w  .j a  v  a2  s  .  c  o  m*/
        return f2;
    }).orElseThrow(IllegalStateException::new);
}

From source file:info.magnolia.photoreview.app.container.InstagramContainer.java

@Override
public Object nextItemId(Object itemId) {
    List<String> keys = new ArrayList<String>(items.keySet());
    int index = keys.indexOf(itemId);
    if (index < keys.size() - 1) {
        return keys.get(index + 1);
    }//from  w  w  w .  j  a v a  2 s  . c  o  m
    return null;
}

From source file:info.magnolia.photoreview.app.container.InstagramContainer.java

@Override
public Object prevItemId(Object itemId) {
    List<String> keys = new ArrayList<String>(items.keySet());
    int index = keys.indexOf(itemId);
    if (index > 0) {
        return keys.get(index - 1);
    }//  w  w w.  j  a va 2  s . co  m
    return null;
}

From source file:it.tidalwave.northernwind.frontend.ui.component.gallery.htmltemplate.bluette.BluetteGalleryAdapter.java

/*******************************************************************************************************************
 *
 * {@inheritDoc}//from  w  ww. j a v a 2  s . c om
 *
 ******************************************************************************************************************/
@Override
public void renderGallery(final @Nonnull GalleryView view, final @Nonnull List<Item> items) {
    final Item item = items.get(0);
    final int itemCount = items.size();
    final int index = items.indexOf(item);
    final Site site = siteProvider.get().getSite();
    final ResourcePath baseUrl = context.getSiteNode().getRelativeUri().prependedWith(site.getContextPath());
    final String previousUrl = site.createLink(
            baseUrl.appendedWith(items.get((index - 1 + itemCount) % itemCount).getId().stringValue()));
    final String nextUrl = site
            .createLink(baseUrl.appendedWith(items.get((index + 1) % itemCount).getId().stringValue()));
    final String lightboxUrl = site.createLink(baseUrl.appendedWith("lightbox"));
    final ST t = new ST(galleryTemplate, '$', '$').add("caption", item.getDescription())
            .add("previous", previousUrl).add("next", nextUrl).add("lightbox", lightboxUrl).add("home", "/blog") // FIXME
            .add("copyright", copyright);
    context.addAttribute("content", t.render());
}

From source file:gov.nih.nci.caarray.plugins.nimblegen.PairDataHandler.java

private void loadDesignElementList(DataSet dataSet, DelimitedFileReader reader, ArrayDesign design)
        throws IOException {
    final DesignElementList probeList = new DesignElementList();
    probeList.setDesignElementTypeEnum(DesignElementType.PHYSICAL_PROBE);
    dataSet.setDesignElementList(probeList);
    final ArrayDesignDetails designDetails = design.getDesignDetails();
    final ProbeLookup probeLookup = new ProbeLookup(designDetails.getProbes());
    final List<String> headers = getHeaders(reader);
    final int seqIdIndex = headers.indexOf(SEQ_ID_HEADER);
    final int probeIdIndex = headers.indexOf(PROBE_ID_HEADER);
    final int containerIndex = headers.indexOf(CONTAINER_HEADER);
    while (reader.hasNextLine()) {
        final List<String> values = reader.nextLine();
        final String probeId = values.get(probeIdIndex);
        final String sequenceId = values.get(seqIdIndex);
        final String container = values.get(containerIndex);
        final String probeName = container + "|" + sequenceId + "|" + probeId;
        probeList.getDesignElements().add(probeLookup.getProbe(probeName));
    }/*from w  w  w .ja va  2s .c om*/
}

From source file:edu.uci.ics.jung.algorithms.blockmodel.StructurallyEquivalent.java

/**
 * For each vertex pair v, v1 in G, checks whether v and v1 are fully
 * equivalent: meaning that they connect to the exact same vertices. (Is
 * this regular equivalence, or whathaveyou?)
 * /*  w  ww  .  j av a  2  s .c  o  m*/
 * Returns a Set of Pairs of vertices, where all the vertices in the inner
 * Pairs are equivalent.
 * 
 * @param g
 */
protected Set<Pair<V>> getEquivalentPairs(Graph<V, ?> g) {

    Set<Pair<V>> rv = new HashSet<Pair<V>>();
    Set<V> alreadyEquivalent = new HashSet<V>();

    List<V> l = new ArrayList<V>(g.getVertices());

    for (V v1 : l) {
        if (alreadyEquivalent.contains(v1))
            continue;

        for (Iterator<V> iterator = l.listIterator(l.indexOf(v1) + 1); iterator.hasNext();) {
            V v2 = iterator.next();

            if (alreadyEquivalent.contains(v2))
                continue;

            if (!canPossiblyCompare(v1, v2))
                continue;

            if (isStructurallyEquivalent(g, v1, v2)) {
                Pair<V> p = new Pair<V>(v1, v2);
                alreadyEquivalent.add(v2);
                rv.add(p);
            }
        }
    }

    return rv;
}

From source file:es.pode.administracion.presentacion.nodos.altaNodo.AltaNodoControllerImpl.java

private List ordenarLista(List listaOrdenada, CcaaVO[] array) {
    CcaaVO[] ccaaOrdenado = new CcaaVO[array.length];
    int posicion = 0;
    for (int i = 0; i < array.length; i++) {
        posicion = listaOrdenada.indexOf(array[i].getDescripcion().toLowerCase());
        ccaaOrdenado[posicion] = array[i];
    }/*from www.j  a  va  2  s . com*/
    return Arrays.asList(ccaaOrdenado);

}