]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.document.server/src/org/simantics/document/server/bean/Command.java
Improvements to modelled SWT documents
[simantics/platform.git] / bundles / org.simantics.document.server / src / org / simantics / document / server / bean / Command.java
1 /*******************************************************************************
2  * Copyright (c) 2019 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.document.server.bean;
13
14 import org.simantics.document.server.io.CommandContext;
15 import org.simantics.document.server.io.ICommand;
16
17 public class Command implements ICommand {
18     
19     public String targetId;
20     public String trigger;
21     public String command;
22     public CommandContext constants;
23
24     public Command() {}
25     
26     public Command(String command) {
27         this.command = command;
28     }
29
30     public Command(String targetId, String trigger, String command, CommandContext constants) {
31         this.targetId = targetId;
32         this.trigger = trigger;
33         this.command = command;     
34         this.constants = constants;
35     }
36
37     public String getTrigger() {
38         return trigger;
39     }
40
41     public String getTargetId() {
42         return targetId;
43     }
44
45     public String getCommand() {
46         return command;
47     }
48
49     @Override
50     public CommandContext getConstants() {
51         return constants;
52     }
53
54     @Override
55     public String toString() {
56         StringBuilder sb = new StringBuilder();
57         sb.append("\n");
58         sb.append(targetId);
59         sb.append("\n");
60         sb.append(trigger);
61         sb.append("\n");
62         sb.append(command);
63         sb.append("\n");
64         sb.append(constants);
65         sb.append("\n");
66         return sb.toString();
67     }
68     
69         @Override
70         public int hashCode() {
71                 final int prime = 31;
72                 int result = 1;
73                 result = prime * result + ((command == null) ? 0 : command.hashCode());
74                 result = prime * result
75                                 + ((constants == null) ? 0 : constants.hashCode());
76                 result = prime * result
77                                 + ((targetId == null) ? 0 : targetId.hashCode());
78                 result = prime * result + ((trigger == null) ? 0 : trigger.hashCode());
79                 return result;
80         }
81
82         @Override
83         public boolean equals(Object obj) {
84                 if (this == obj)
85                         return true;
86                 if (obj == null)
87                         return false;
88                 if (getClass() != obj.getClass())
89                         return false;
90                 Command other = (Command) obj;
91                 if (command == null) {
92                         if (other.command != null)
93                                 return false;
94                 } else if (!command.equals(other.command))
95                         return false;
96                 if (constants == null) {
97                         if (other.constants != null)
98                                 return false;
99                 } else if (!constants.equals(other.constants))
100                         return false;
101                 if (targetId == null) {
102                         if (other.targetId != null)
103                                 return false;
104                 } else if (!targetId.equals(other.targetId))
105                         return false;
106                 if (trigger == null) {
107                         if (other.trigger != null)
108                                 return false;
109                 } else if (!trigger.equals(other.trigger))
110                         return false;
111                 return true;
112         }
113     
114     
115 }