View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.theplugin.idea.config.serverconfig.model;
18  
19  import com.atlassian.theplugin.commons.ServerType;
20  import com.atlassian.theplugin.commons.cfg.ServerCfg;
21  
22  import javax.swing.tree.DefaultMutableTreeNode;
23  
24  public class ServerNode extends DefaultMutableTreeNode {
25  	private final ServerCfg server;
26  
27  	public ServerNode(ServerCfg aServer) {
28  		this.server = aServer;
29  	}
30  
31      public ServerType getServerType() {
32          return server.getServerType(); 
33      }
34  
35      public ServerCfg getServer() {
36  		return server;
37  	}
38  
39      /**
40       * Used ultimately by {@link javax.swing.tree.DefaultTreeCellRenderer}. so it must be like this
41       * Sorry :(
42       *
43       * @return server name
44       */
45      @Override
46      public String toString() {
47  		return server.getName();
48  	}
49  
50  	public boolean equals(Object o) {
51  		if (this == o) {
52  			return true;
53  		}
54  		if (o == null || getClass() != o.getClass()) {
55  			return false;
56  		}
57  
58  		ServerNode that = (ServerNode) o;
59  
60  		if (!server.equals(that.server)) {
61  			return false;
62  		}
63  
64  		return true;
65  	}
66  
67  	public int hashCode() {
68  		return server.hashCode();
69  	}
70  }