]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/method/MethodType.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / method / MethodType.java
diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/method/MethodType.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/method/MethodType.java
new file mode 100644 (file)
index 0000000..f683ffa
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************\r
+ *  Copyright (c) 2010 Association for Decentralized Information Management in\r
+ *  Industry THTH ry.\r
+ *  All rights reserved. This program and the accompanying materials\r
+ *  are made available under the terms of the Eclipse Public License v1.0\r
+ *  which accompanies this distribution, and is available at\r
+ *  http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ *  Contributors:\r
+ *      VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.method;
+
+import org.simantics.databoard.type.Datatype;\r
+
+public class MethodType implements Comparable<MethodType> {
+       
+       // RecordType, one component for each argument
+       Datatype requestType;
+       // anything
+       Datatype responseType;
+       // UnionType
+       Datatype errorType;
+       
+       transient int hash; 
+       \r
+       /**\r
+        * \r
+        * @param requestType\r
+        * @param responseType\r
+        * @param errorType must be union\r
+        */
+       public MethodType(Datatype requestType, Datatype responseType, Datatype errorType)
+       {
+               this.requestType = requestType;
+               this.responseType = responseType;
+               this.errorType = errorType;
+               hash = requestType.hashCode() + responseType.hashCode()*13 + errorType.hashCode()*23;
+       }
+       
+       public Datatype getRequestType()
+       {
+               return requestType;
+       }
+       
+       public Datatype getResponseType()
+       {
+               return responseType;
+       }
+       
+       public Datatype getErrorType()
+       {
+               return errorType;
+       }
+       
+       @Override
+       public String toString() {\r
+               return requestType.toSingleLineString()+" -> " + responseType.toSingleLineString()+ " throws " + errorType.toSingleLineString();\r
+       }
+       
+
+       @Override
+       public int hashCode() {
+               return hash;
+       }
+       
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof MethodType == false) return false;
+               MethodType other = (MethodType) obj;
+               return other.requestType.equals(requestType) && 
+                       other.responseType.equals(responseType) &&
+                       other.errorType.equals(errorType);
+       }
+
+       @Override
+       public int compareTo(MethodType o) {
+               return 0;
+       }
+       
+}
+