]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.management/src/org/simantics/db/management/discovery/ServerInfo.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.management / src / org / simantics / db / management / discovery / ServerInfo.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.db.management.discovery;\r
13 \r
14 import org.simantics.db.service.ServerInformation;\r
15 \r
16 \r
17 /**\r
18  * @author Tuukka Lehtonen\r
19  */\r
20 public class ServerInfo {\r
21 \r
22     public static final ServerInfo[] NONE = {};\r
23 \r
24     private final String             name;\r
25 \r
26 //    private final ServerAddress  address;\r
27     \r
28     private final ServerInformation  info;\r
29     \r
30     private final String aux_info;\r
31 \r
32     /**\r
33      * @param name\r
34      * @param address\r
35      * @throws IllegalArgumentException if the address is not in host:port\r
36      *         format\r
37      */\r
38 //    public ServerInfo(String name, String address) throws IllegalArgumentException {\r
39 //        this(name, address, null, null);\r
40 //    }\r
41     \r
42 //    public ServerInfo(String name, String address, String aux_info) throws IllegalArgumentException {\r
43 //        this(name, address, null, aux_info);\r
44 //    }\r
45 //\r
46 //    public ServerInfo(String name) {\r
47 //        this(name, null);\r
48 //    }\r
49 //    \r
50 //    public ServerInfo(String name, String aux_info) {\r
51 //        this(name, aux_info, null);\r
52 //    }\r
53 //\r
54 //    public ServerInfo(String name, String address, ServerInformation info) throws IllegalArgumentException {\r
55 //        this(name, address, info, null);\r
56 //    }\r
57 //\r
58     public ServerInfo(String name, ServerInformation info, String aux_info) throws IllegalArgumentException {\r
59         this.name = name;\r
60 //        this.address = address == null ? null : new ServerAddress(address);\r
61         this.info = info;\r
62         this.aux_info = aux_info;\r
63     }\r
64 //\r
65 //    public ServerInfo(String name, ServerInformation info) {\r
66 //        this(name, address, info, null);\r
67 //    }\r
68 //    \r
69 //    public ServerInfo(String name, ServerInformation info, String aux_info) {\r
70 //        this.name = name;\r
71 ////        this.address = address;\r
72 //        this.info = info;\r
73 //        this.aux_info = aux_info;\r
74 //    }\r
75 \r
76     public String getName() {\r
77         return name;\r
78     }\r
79 \r
80 //    public ServerAddress getAddress() {\r
81 //        return address;\r
82 //    }\r
83 \r
84     public ServerInformation getInfo() {\r
85         return info;\r
86     }\r
87     \r
88     public String getAuxInfo() {\r
89         return aux_info;\r
90     }\r
91 \r
92     @Override\r
93     public String toString() {\r
94         String str = name + " "; //+ address;\r
95         if(aux_info != null)\r
96                 str += " "+aux_info;\r
97         return str;\r
98     }\r
99 \r
100     @Override\r
101     public int hashCode() {\r
102         return ((name == null) ? 0 : name.hashCode());\r
103     }\r
104 \r
105     @Override\r
106     public boolean equals(Object obj) {\r
107         if (this == obj)\r
108             return true;\r
109         if (obj == null || getClass() != obj.getClass())\r
110             return false;\r
111         final ServerInfo other = (ServerInfo) obj;\r
112 //        if (address == null) {\r
113 //            if (other.address != null)\r
114 //                return false;\r
115 //            // The name field is used for equals\r
116 //            // only when the address is null.\r
117 //            if (!name.equals(other.name))\r
118 //                return false;\r
119 //        } else if (!address.equals(other.address))\r
120 //            return false;\r
121         return true;\r
122     }\r
123 \r
124 //    public ServerInfo withAddress(ServerAddress address) {\r
125 //        return new ServerInfo(name, address);\r
126 //    }\r
127 \r
128 }\r