Java Set Compare compareSets(Set resSet, Set initSet)

Here you can find the source of compareSets(Set resSet, Set initSet)

Description

compare Sets

License

Open Source License

Declaration

private static Set compareSets(Set resSet, Set initSet) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2008 Intel Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://ww  w  . j  a v a 2  s.  co m
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/

import java.util.Collections;

import java.util.Set;

public class Main {
    private static Set compareSets(Set resSet, Set initSet) {
        Set result = null;
        if (initSet == null || initSet.isEmpty()) {
            if (resSet != null && !resSet.isEmpty()) {
                result = resSet;
            }
        } else if (resSet == null || resSet.isEmpty()) {
            result = Collections.EMPTY_SET;
        } else {
            if (!initSet.equals(resSet)) {
                result = resSet;
            }
        }

        return result;
    }
}

Related

  1. compareSet(Set set1, Set set2)