Java List IndexOf indexOf(List lines, String... conditions)

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

Description

index Of

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;

import java.util.List;

public class Main {
    public static int indexOf(List<String> lines, String... conditions) {
        int i = 0;
        for (String line : lines) {
            if (matchLine(line, conditions))
                return i;
            i++;/*from  w ww.j a v a  2s  . c o 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. indexOf(int hash, List list)
  2. indexOf(int start, List datas, T target)
  3. indexOf(List list, Object element, int begin, int end)
  4. indexOf(List data, List token)
  5. indexOf(List source, List target)
  6. indexOf(List list, T string, int beginIndex)
  7. indexOf(Object o, Collection list)
  8. indexOfFactory(List factories, Class classInstance)
  9. indexOfId(List aList, Object anObj)