Java List Last Item lastIndexOf(List lines, String... conditions)

Here you can find the source of lastIndexOf(List lines, String... conditions)

Description

last Index Of

License

Open Source License

Declaration

public static int lastIndexOf(List<String> lines, String... conditions) 

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    public static int lastIndexOf(List<String> lines, String... conditions) {
        for (int i = lines.size() - 1; i >= 0; i--) {
            String line = lines.get(i);
            if (matchLine(line, conditions))
                return i;
        }/*from  www.j  a  v  a  2  s  .  co m*/
        return -1;
    }

    private static boolean matchLine(String line, String[] conditions) {
        for (String condition : conditions) {
            boolean exclude = false;
            if (condition.startsWith("\\")) {
                exclude = true;
                condition = condition.substring(1);
            }
            if (exclude && line.contains(condition))
                return false;
            if (!exclude && !line.contains(condition))
                return false;
        }
        return true;
    }
}

Related

  1. isLast(List list, Object o)
  2. isLast(T object, List list)
  3. isLastIdx(List l, int idx)
  4. isLastIndex(List list, int index)
  5. isLastIndex(List suggestedList, int i)
  6. lastIndexOfIdentical(List l, T element, int startingAt)
  7. listToWorkspaceLocationHistoryString(List lastUsedWorkspaceLocationList)
  8. removeBySwapLast(List a, Object o)
  9. removeLast(List list)