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

TfirstUnique(List list)
first Unique
List<T> temp = new ArrayList<>(list);
for (int i = 0; i < temp.size(); i++) {
    T elem = temp.get(i);
    temp.remove(elem);
    if (!temp.contains(elem)) {
        return elem;
return null;
TfirstValue(List list)
Returns the first value of a list, or null if the list is empty.
if (list != null && !list.isEmpty()) {
    return list.get(0);
return null;
StringformatEJBQLObjectRangeRestriction(final String fieldName, final Object value1, final Object value2, final String paramName1, final String paramName2, List paramsName, List paramsValue, boolean firstRestriction)
format EJBQL Object Range Restriction
String result = "";
if (value1 != null && value1.equals(value2)) {
    result = String.format("(%s = :%s)", fieldName, paramName1);
    paramsName.add(paramName1);
    paramsValue.add(value1);
} else if (value1 != null || value2 != null) {
    if (value1 == null) {
        result = String.format("(%s <= :%s)", fieldName, paramName2);
...
StringformatEJBQLObjectRestriction(final String fieldName, final Object value, final String paramName, List paramsName, List paramsValue, boolean firstRestriction)
format EJBQL Object Restriction
String result = "";
if (value != null) {
    result = String.format("(%s = :%s)", fieldName, paramName);
    paramsName.add(paramName);
    paramsValue.add(value);
    result = generateRestrictionPrefix(result, firstRestriction);
return result;
...
ListgetAllButFirst(List list)
get All But First
Iterator<T> iterator = list.iterator();
iterator.next();
LinkedList<T> result = new LinkedList<T>();
addAll(result, iterator);
return result;
StringgetDependenciesPrivate(List projects, boolean firstDependencies)
get Dependencies Private
if (projects.isEmpty()) {
    return "";
StringBuilder builder = new StringBuilder();
if (!firstDependencies) {
    builder.append(",");
builder.append(getCompileTargetName(projects.get(0)));
...
TgetFirst(List c)
get First
if (c == null || c.size() == 0)
    return null;
return c.get(0);
TgetFirst(List l)
Return the first item of l if it isn't empty, otherwise null.
return getNoExn(l, 0);
TgetFirst(List list)
get First
if (isEmpty(list)) {
    return null;
return list.get(0);
TgetFirst(List list)
Returns the first element in a list, or null if there is none.
return list == null || list.isEmpty() ? null : list.get(0);