Java Serializable Compare areEqual(Serializable value1, Serializable value2)

Here you can find the source of areEqual(Serializable value1, Serializable value2)

Description

check if two serializable values are the same

License

Open Source License

Parameter

Parameter Description
value1 a parameter
value2 a parameter

Return

true if they are equal

Declaration

public static boolean areEqual(Serializable value1, Serializable value2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Crafter Studio Web-content authoring solution
 *     Copyright (C) 2007-2013 Crafter Software Corporation.
 * //from w  w w  . j  av a  2s .co  m
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

import java.io.*;

public class Main {
    /**
     * check if two serializable values are the same
     * 
     * @param value1
     * @param value2
     * @return true if they are equal
     */
    public static boolean areEqual(Serializable value1, Serializable value2) {
        if (value1 == null && value2 == null) {
            return true;
        } else if (value1 == null || value2 == null) {
            return false;
        } else {
            return value1.equals(value2);
        }
    }
}