ProtocolDescription.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Google Inc.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 
00017 package org.ros.internal.transport;
00018 
00019 import java.net.InetSocketAddress;
00020 import java.util.List;
00021 
00022 import org.ros.address.AdvertiseAddress;
00023 
00024 import com.google.common.collect.Lists;
00025 
00029 public class ProtocolDescription {
00030 
00031   private final String name;
00032   private final AdvertiseAddress address;
00033 
00034   public ProtocolDescription(String name, AdvertiseAddress address) {
00035     this.name = name;
00036     this.address = address;
00037   }
00038 
00039   public String getName() {
00040     return name;
00041   }
00042 
00043   public AdvertiseAddress getAdverstiseAddress() {
00044     return address;
00045   }
00046   
00047   public InetSocketAddress getAddress() {
00048     return address.toInetSocketAddress();
00049   }
00050 
00051   public List<Object> toList() {
00052     return Lists.newArrayList((Object) name, address.getHost(), address.getPort());
00053   }
00054 
00055   @Override
00056   public String toString() {
00057     return "Protocol<" + name + ", " + getAdverstiseAddress() + ">";
00058   }
00059 
00060   @Override
00061   public int hashCode() {
00062     final int prime = 31;
00063     int result = 1;
00064     result = prime * result + ((address == null) ? 0 : address.hashCode());
00065     result = prime * result + ((name == null) ? 0 : name.hashCode());
00066     return result;
00067   }
00068 
00069   @Override
00070   public boolean equals(Object obj) {
00071     if (this == obj)
00072       return true;
00073     if (obj == null)
00074       return false;
00075     if (getClass() != obj.getClass())
00076       return false;
00077     ProtocolDescription other = (ProtocolDescription) obj;
00078     if (address == null) {
00079       if (other.address != null)
00080         return false;
00081     } else if (!address.equals(other.address))
00082       return false;
00083     if (name == null) {
00084       if (other.name != null)
00085         return false;
00086     } else if (!name.equals(other.name))
00087       return false;
00088     return true;
00089   }
00090 
00091 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49