Debian Codegraph @

bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/PropertyOperand.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2008, 2017 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.equinox.internal.p2.engine;
15
16 import org.eclipse.core.runtime.Assert;
17
18 /**
19 * @since 2.0
20 */
21 public class PropertyOperand extends Operand {
22 private final Object first;
23 private final Object second;
24 private final String key;
25
26 /**
27 * Creates a new operand that represents replacing a property value
28 * with another. At least one of the provided property values must be
29 * non-null.
30 *
31 * @param key The key of the property being modified
32 * @param first The property value being removed, or <code>null</code>
33 * @param second The property value being added, or <code>null</code>
34 */
35 public PropertyOperand(String key, Object first, Object second) {
36 //the operand must specify have a key and have at least one non-null value
37 Assert.isTrue(key != null && (first != null || second != null));
38 this.first = first;
39 this.second = second;
40 this.key = key;
41 }
42
43 public Object first() {
44 return first;
45 }
46
47 public Object second() {
48 return second;
49 }
50
51 public String getKey() {
52 return key;
53 }
54
55 @Override
56 public String toString() {
57 return key + " = " + first + " --> " + second; //$NON-NLS-1$ //$NON-NLS-2$
58 }
59 }