BindAddress.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.address;
00018 
00019 import java.net.InetSocketAddress;
00020 
00028 public class BindAddress {
00029 
00030   private final InetSocketAddress address;
00031 
00032   private BindAddress(InetSocketAddress address) {
00033     this.address = address;
00034   }
00035 
00041   public static BindAddress newPublic(int port) {
00042     return new BindAddress(new InetSocketAddress(port));
00043   }
00044 
00045   public static BindAddress newPublic() {
00046     return newPublic(0);
00047   }
00048 
00054   public static BindAddress newPrivate(int port) {
00055     return new BindAddress(new InetSocketAddress(InetAddressFactory.newLoopback(), port));
00056   }
00057 
00058   public static BindAddress newPrivate() {
00059     return newPrivate(0);
00060   }
00061 
00062   @Override
00063   public String toString() {
00064     return "BindAddress<" + address + ">";
00065   }
00066 
00067   public InetSocketAddress toInetSocketAddress() {
00068     return address;
00069   }
00070 
00071   @Override
00072   public int hashCode() {
00073     final int prime = 31;
00074     int result = 1;
00075     result = prime * result + ((address == null) ? 0 : address.hashCode());
00076     return result;
00077   }
00078 
00079   @Override
00080   public boolean equals(Object obj) {
00081     if (this == obj) return true;
00082     if (obj == null) return false;
00083     if (getClass() != obj.getClass()) return false;
00084     BindAddress other = (BindAddress) obj;
00085     if (address == null) {
00086       if (other.address != null) return false;
00087     } else if (!address.equals(other.address)) return false;
00088     return true;
00089   }
00090 
00091 }


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