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.Set;

public class Main {
    public static <T> Set<T> toImmutableSet(Set<T> set) {
        switch (set.size()) {
        case 0:
            return Collections.emptySet();
        case 1:
            return Collections.singleton(set.iterator().next());
        default:
            return Collections.unmodifiableSet(set);
        }
    }
}