]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/internal/ObjectUtils.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / internal / ObjectUtils.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.utils.datastructures.internal;
13
14 /**
15  * @author Toni Kalajainen
16  */
17 public class ObjectUtils {
18
19     /**
20      * Compares two object for equality.
21      * <p>
22      * Some times it is annoying to compare two objects if their value may be
23      * null.
24      * 
25      * @param o1 obj1
26      * @param o2 obj2
27      * @return true if equal or both null
28      */
29     public static boolean objectEquals(Object o1, Object o2) {
30         if (o1 == o2)
31             return true;
32         if (o1 == null && o2 == null)
33             return true;
34         if (o1 == null || o2 == null)
35             return false;
36         return o1.equals(o2);
37     }
38
39 }