Java Utililty Methods List First Item

List of utility methods to do List First Item

Description

The list of methods to do List First Item are organized into topic(s).

Method

ListgetFirstRowResults(List> llo, String reason)
Gets the first row results.
if (llo.size() < 1)
    throw new RuntimeException("Insufficient row results, " + reason);
return llo.get(0);
StringgetFirstString(Object list)
unqualify given dateVal.
if (list == null) {
    return null;
if (list instanceof List) {
    return ((List) list).size() == 0 ? null : (String) ((List) list).get(0);
Class<?> arrType = list.getClass().getComponentType();
if ((arrType != null) && arrType.isPrimitive()) {
...
StringgetFirstValueString(List values)
get First Value String
if (values.isEmpty()) {
    return null;
Object first = values.get(0);
return first != null ? first.toString() : null;
StringgetFirstValueString(List values)
Gets the first value of the given list of values.
if ((values != null) && !values.isEmpty()) {
    return values.get(0);
return null;
intgetIndexOfFirstMatchingProperty(List propertyNames, String follower)
get Index Of First Matching Property
int propertySize = propertyNames.size();
for (int propIndex = 0; propIndex < propertySize; propIndex++) {
    if (((String) propertyNames.get(propIndex)).startsWith(follower)) {
        return propIndex;
return -1;
ListgetListBetween(String inputStr, String first, String second, List list)
get List Between
String str = inputStr;
int idx = str.indexOf(first);
while (idx > 0) {
    list.add(getStringBetween(str, first, second));
    str = str.substring(idx + first.length());
    idx = str.indexOf(first);
return list;
...
byte[]getNFirstBytes(int n, List byteList)
get N First Bytes
List<Byte> nFirstByteList = byteList.subList(0, n);
byte[] nFirstBytes = new byte[n];
for (int i = 0; i < nFirstByteList.size(); i++) {
    nFirstBytes[i] = nFirstByteList.get(i);
return nFirstBytes;
ObjectgetOnlyFirst(List obj)
get Only First
if (obj.size() == 1) {
    return obj.get(0);
} else {
    return null;
ListgetPage(List all, int first, int pageSize)
get Page
int last = first + pageSize;
if (last > all.size()) {
    last = all.size();
return all.subList(first, last);
StringgetStringFirstResult(List> llo, String reason)
Gets the string first result.
Object o = getNthResult(llo, 0, reason);
if (!(o instanceof String))
    throw new RuntimeException("Result not String, " + reason);
return (String) getNthResult(llo, 0, reason);