Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/* 
 * This file is part of the HyperGraphDB source distribution. This is copyrighted 
 * software. For permitted uses, licensing options and redistribution, please see  
 * the LicensingInformation file at the root level of the distribution.  
 * 
 * Copyright (c) 2005-2010 Kobrix Software, Inc.  All rights reserved. 
 */

public class Main {
    /**
     * <p>
     * Compare two objects for equality, checking for <code>null</code> values as well.
     * </p>
     */
    public static boolean eq(Object left, Object right) {
        if (left == right)
            return true;
        else if (left == null)
            return false;
        else if (right == null)
            return false;
        else
            return left.equals(right);
    }

    /**
     * <p>Compare two arrays for equality. This will perform a deep comparison, return
     * <code>true</code> if and only if all elements of the passed in arrays are equal.</p> 
     */
    public static boolean eq(Object[] left, Object[] right) {
        if (left == right)
            return true;
        else if (left == null || right == null)
            return false;
        else if (left.length != right.length)
            return false;
        for (int i = 0; i < left.length; i++)
            if (!eq(left[i], right[i]))
                return false;
        return true;
    }

    public static boolean eq(byte[] left, byte[] right) {
        if (left == right)
            return true;
        else if (left == null || right == null || left.length != right.length)
            return false;
        for (int i = 0; i < left.length; i++)
            if (left[i] != right[i])
                return false;
        return true;
    }
}