Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
 */

import java.util.Collections;

import java.util.List;

public class Main {
    public static <T> List<T> toImmutableList(List<T> list) {
        switch (list.size()) {
        case 0:
            return Collections.emptyList();
        case 1:
            return Collections.singletonList(list.get(0));
        default:
            return Collections.unmodifiableList(list);
        }
    }
}