Debian Codegraph @

bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointData.java

raw
1 /*******************************************************************************
2 * Copyright (c) 2007, 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 * EclipseSource - ongoing development
14 *******************************************************************************/
15 package org.eclipse.equinox.internal.p2.metadata;
16
17 import java.util.Collections;
18 import java.util.Map;
19 import java.util.Map.Entry;
20 import org.eclipse.equinox.p2.metadata.*;
21
22 /**
23 * Touchpoint data instances contain the additional information needed by a touchpoint
24 * to execute each engine phase it participates in. This includes the sequence of
25 * instruction statements to be executed during each phase, and any additional
26 * supporting data needed to perform the phase.
27 *
28 * @noextend This class is not intended to be subclassed by clients.
29 * @see MetadataFactory#createTouchpointData(Map)
30 */
31 public class TouchpointData implements ITouchpointData {
32
33 /**
34 * Map of (String->TouchpointInstruction). The set
35 * of keys supported is up to the touchpoint that will process these
36 * instructions. This map is never null.
37 */
38 private Map<String, ITouchpointInstruction> instructions;
39
40 @Override
41 public int hashCode() {
42 return 31 * 1 + ((instructions == null) ? 0 : instructions.hashCode());
43 }
44
45 @Override
46 public boolean equals(Object obj) {
47 if (this == obj)
48 return true;
49 if (obj == null)
50 return false;
51 if (!(obj instanceof ITouchpointData))
52 return false;
53 final ITouchpointData other = (ITouchpointData) obj;
54 if (instructions == null) {
55 if (other.getInstructions() != null)
56 return false;
57 } else if (!instructions.equals(other.getInstructions()))
58 return false;
59 return true;
60 }
61
62 /**
63 * Clients must use the factory method on {@link MetadataFactory}.
64 */
65 public TouchpointData(Map<String, ITouchpointInstruction> instructions) {
66 this.instructions = instructions;
67 }
68
69 /**
70 * Returns the touchpoint instruction corresponding to the given key.
71 */
72 @Override
73 public ITouchpointInstruction getInstruction(String instructionKey) {
74 return instructions.get(instructionKey);
75 }
76
77 /**
78 * Returns an unmodifiable map of the touchpoint instructions. The map
79 * keys are strings, and the values are instances of {@link ITouchpointInstruction}.
80 *
81 * @return the touchpoint instructions
82 */
83 @Override
84 public Map<String, ITouchpointInstruction> getInstructions() {
85 return Collections.unmodifiableMap(instructions);
86 }
87
88 /**
89 * Returns a string representation of the touchpoint data for debugging purposes only.
90 */
91 @Override
92 public String toString() {
93 StringBuilder result = new StringBuilder();
94 for (Entry<String, ITouchpointInstruction> instruction : instructions.entrySet()) {
95 result.append(instruction.getKey()).append(" -> ").append(instruction.getValue()).append('\n'); //$NON-NLS-1$
96 }
97 return result.toString();
98 }
99 }