Debian Codegraph @

bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileEvent.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 *******************************************************************************/
14 package org.eclipse.equinox.internal.p2.engine;
15
16 import java.util.EventObject;
17 import org.eclipse.equinox.p2.engine.IProfileEvent;
18
19 /**
20 * @noextend This class is not intended to be subclassed by clients.
21 * @since 2.0
22 */
23 public class ProfileEvent extends EventObject implements IProfileEvent {
24 private static final long serialVersionUID = 3082402920617281765L;
25
26 private int reason;
27
28 public ProfileEvent(String profileId, int reason) {
29 super(profileId);
30 this.reason = reason;
31 }
32
33 @Override
34 public int getReason() {
35 return reason;
36 }
37
38 @Override
39 public String getProfileId() {
40 return (String) getSource();
41 }
42
43 @Override
44 public String toString() {
45 StringBuilder buffer = new StringBuilder();
46 buffer.append("ProfileEvent["); //$NON-NLS-1$
47 buffer.append(getProfileId());
48 buffer.append("-->"); //$NON-NLS-1$
49 switch (reason) {
50 case IProfileEvent.ADDED :
51 buffer.append("ADDED"); //$NON-NLS-1$
52 break;
53 case IProfileEvent.REMOVED :
54 buffer.append("REMOVED"); //$NON-NLS-1$
55 break;
56 case IProfileEvent.CHANGED :
57 buffer.append("CHANGED"); //$NON-NLS-1$
58 break;
59 }
60 buffer.append("] "); //$NON-NLS-1$
61 return buffer.toString();
62 }
63 }