package brooklyn.location.access;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.base.Objects;

import brooklyn.location.Location;

public class PortMapping {
    
    public PortMapping(String publicIpId, int publicPort, Location target, int privatePort) {
        super();
        this.publicIpId = checkNotNull(publicIpId, "publicIpId");
        this.publicPort = publicPort;
        this.target = target;
        this.privatePort = privatePort;
    }

    final String publicIpId;
    final int publicPort;

    final Location target;
    final int privatePort;
    // CIDR's ?

    public int getPublicPort() {
        return publicPort;
    }

    public Location getTarget() {
        return target;
    }
    public int getPrivatePort() {
        return privatePort;
    }
    
    @Override
    public String toString() {
        return Objects.toStringHelper(this).add("public", publicIpId+":"+publicPort).
                add("private", target+":"+privatePort).toString();
    }
}
@@ -1028,9 +1028,534 @@
 ;%0A    %7D%0A
+    %0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (!(obj instanceof PortMapping)) return false;%0A        PortMapping opm = (PortMapping)obj;%0A        return Objects.equal(publicIpId, opm.publicIpId) &&%0A            Objects.equal(publicPort, opm.publicPort) &&%0A            Objects.equal(target, opm.target) &&%0A            Objects.equal(privatePort, opm.privatePort);%0A    %7D%0A    %0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hashCode(publicIpId, publicPort, target, privatePort);%0A    %7D%0A    %0A
 %7D

add equals and tostring for PortMapping