Skip to main content
summaryrefslogtreecommitdiffstats
blob: e3c238dc4d4ef8dc70b39ef3d8c40e78eb80f7cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************************
 * Copyright (c) 2009, 2010 Oracle. 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:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.common.utility.internal;

/**
 * Various utility methods.
 */
@SuppressWarnings("nls")
public final class Tools {

	// ********** object comparison **********

	/**
	 * Return whether the specified values are equal, with the appropriate
	 * <code>null</code> checks.
	 */
	public static boolean valuesAreEqual(Object value1, Object value2) {
		return (value1 == null) ?
				(value2 == null) :
				((value2 != null) && value1.equals(value2));
	}

	/**
	 * Return whether the specified values are different, with the appropriate
	 * <code>null</code> checks.
	 */
	public static boolean valuesAreDifferent(Object value1, Object value2) {
		return (value1 == null) ?
				(value2 != null) :
				((value2 == null) || ! value1.equals(value2));
	}


	// ********** System properties **********

	/**
	 * Return whether the current JVM is Sun's (or Oracle's).
	 */
	public static boolean jvmIsSun() {
		return jvmIs("Sun") || jvmIs("Oracle");
	}

	/**
	 * Return whether the current JVM is IBM's.
	 */
	public static boolean jvmIsIBM() {
		return jvmIs("IBM");
	}

	private static boolean jvmIs(String jvmVendorName) {
		return System.getProperty("java.vendor").startsWith(jvmVendorName);
	}

	/**
	 * Return whether the current operating system is Microsoft Windows.
	 */
	public static boolean osIsWindows() {
		return osIs("Windows");
	}

	/**
	 * Return whether the current operating system is Linux.
	 */
	public static boolean osIsLinux() {
		return osIs("Linux");
	}

	private static boolean osIs(String osName) {
		return System.getProperty("os.name").indexOf(osName) != -1;
	}


	// ********** constructor **********

	/**
	 * Suppress default constructor, ensuring non-instantiability.
	 */
	private Tools() {
		super();
		throw new UnsupportedOperationException();
	}
}

Back to the top