Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java')
-rw-r--r--bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java
new file mode 100644
index 000000000..487cca321
--- /dev/null
+++ b/bundles/org.eclipse.wst.wsi/src/org/eclipse/wst/wsi/internal/core/util/NullUtil.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2002-2005 IBM 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:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.wsi.internal.core.util;
+
+/**
+ * The utility class to automate null checking.
+ *
+ * @author Kulik
+ */
+public final class NullUtil
+{
+ /**
+ * The method checks objects on existence and compare with <code>equals</code> method.
+ * @param o1 first object.
+ * @param o2 second object.
+ * @return true if first object is equal to the second object.
+ */
+ public static boolean equals(Object o1, Object o2)
+ {
+ return ((o1 == null && o2 == null) || (o1 != null && o1.equals(o2)));
+ }
+
+ /**
+ * The method checks object on existence and returns its string representation with <code>toString()</code> method.
+ * @param o source object.
+ * @return string representation of object.
+ */
+ public static String toString(Object o)
+ {
+ return (o == null) ? null : o.toString();
+ }
+}

Back to the top