001package csheets.ext.share.core;
002
003import java.net.InetAddress;
004
005/**
006 * Class with IP and port, that will serve the server and client discover
007 * 
008 * @author Andre
009 * 
010 */
011public class Connections {
012
013        /** port of the server */
014        private final int port;
015        /** IP of the server */
016        private final InetAddress IP;
017
018        /**
019         * Create a new connection class
020         * 
021         * @param port
022         *            por of the server
023         * @param inetAddress
024         *            ip of the server
025         */
026        public Connections(int port, InetAddress ip) {
027                this.port = port;
028                this.IP = ip;
029        }
030
031        /**
032         * Get the ip address of the connection
033         * 
034         * @return the ip address
035         */
036        public InetAddress getIP() {
037                return IP;
038        }
039
040        /**
041         * Get the port of the connection
042         * 
043         * @return the port
044         */
045        public int getPort() {
046                return port;
047        }
048
049        @Override
050        public String toString() {
051                return IP + ":" + port;
052        }
053
054        @Override
055        public boolean equals(Object obj) {
056                if (obj instanceof Connections) {
057                        return (IP.equals(((Connections) obj).IP) && (port == ((Connections) obj).port));
058                }
059                return false;
060        }
061}