1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.databoard.method;
14 import java.util.Set;
\r
15 import java.util.TreeSet;
\r
18 * An interface, a description of methods.
20 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
22 public class Interface {
24 Set<MethodTypeDefinition> methodDefinitions = new TreeSet<MethodTypeDefinition>( MethodTypeDefinition.BINDING );
30 public Interface(MethodTypeDefinition...methodDefs)
32 for (MethodTypeDefinition def : methodDefs)
34 methodDefinitions.add(def);
39 * Add new method definition
43 void add(MethodTypeDefinition methodDef)
45 methodDefinitions.add(methodDef);
51 * @param methodDef method type definition
53 public void remove(MethodTypeDefinition methodDef)
55 if ( !methodDefinitions.remove(methodDef) ) return;
59 * Get ordered list of method descriptions
61 * @return method descriptions
63 public MethodTypeDefinition[] getMethodDefinitions() {
64 return methodDefinitions.toArray(new MethodTypeDefinition[methodDefinitions.size()]);
68 * Get ordered list of method descriptions
70 * @return method descriptions
72 public Set<MethodTypeDefinition> getMethodDefinitionSet() {
73 return methodDefinitions;
77 public String toString() {
78 if (methodDefinitions.isEmpty()) return "{}";
80 StringBuilder sb = new StringBuilder();
82 for (MethodTypeDefinition def : methodDefinitions) {
92 public boolean equals(Object obj) {
93 if (obj instanceof Interface == false) return false;
94 Interface other = (Interface) obj;
95 if (!other.methodDefinitions.equals( methodDefinitions )) return false;
100 public int hashCode() {
101 int result = 0x3a44a54a;
102 for (MethodTypeDefinition def : methodDefinitions)
103 result += def.hashCode();