Java List First Item isFirst(List list, V object)

Here you can find the source of isFirst(List list, V object)

Description

is First

License

Apache License

Declaration

public static <V> boolean isFirst(List<V> list, V object) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;

public class Main {
    public static <V> boolean isFirst(List<V> list, V object) {
        V first = getFirst(list);//from  w w  w.j  a  v a2s .  c  o m
        return first.equals(object);
    }

    public static <V> V getFirst(List<V> list) {
        return getFirst(list, null);
    }

    public static <V> V getFirst(List<V> list, V defaultValue) {
        int size = list.size();

        if (size > 0) {
            return list.get(0);
        } else {
            return defaultValue;
        }
    }

    public static <V> V get(List<V> list, int index, V defaultValue) {
        try {
            return list.get(index);
        } catch (Exception ignore) {
        }

        return defaultValue;
    }
}

Related

  1. getNFirstBytes(int n, List byteList)
  2. getOnlyFirst(List obj)
  3. getPage(List all, int first, int pageSize)
  4. getStringFirstResult(List> llo, String reason)
  5. hasSameElement(List firstList, List secondList)
  6. isFirstAnnotationOfMethod(List lines, int lineNumber)
  7. isFirstPage(List pageLines, List> rawPages)
  8. isInOrder(List src, Object first, Object second)
  9. limit(List list, Long firstResult, Long maxResults)