blob: d9d1e218821e8250359182c64ada4b24a4901efc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*******************************************************************************
* Copyright (c) 2014, 2015 Red Hat.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat - Initial Contribution
*******************************************************************************/
package org.eclipse.linuxtools.internal.docker.core;
import org.eclipse.linuxtools.docker.core.IDockerContainer;
import org.eclipse.linuxtools.docker.core.IDockerPortMapping;
/**
* Port mapping for {@link IDockerContainer}
* @author xcoulon
*
*/
public class DockerPortMapping implements IDockerPortMapping {
private final int privatePort;
private final int publicPort;
private final String type;
private final String ip;
private final IDockerContainer container;
/**
* Full constructor
*
* @param container
* the parent container
*
* @param privatePort
* private port
* @param publicPort
* public port
* @param type
* of port
* @param ip
* of port
*/
public DockerPortMapping(final IDockerContainer container,
final int privatePort, final int publicPort,
final String type, final String ip) {
this.container = container;
this.privatePort = privatePort;
this.publicPort = publicPort;
this.type = type;
this.ip = ip;
}
@Override
public IDockerContainer getContainer() {
return this.container;
}
@Override
public int getPrivatePort() {
return this.privatePort;
}
@Override
public int getPublicPort() {
return this.publicPort;
}
@Override
public String getType() {
return this.type;
}
@Override
public String getIp() {
return ip;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
result = prime * result + privatePort;
result = prime * result + publicPort;
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DockerPortMapping other = (DockerPortMapping) obj;
if (ip == null) {
if (other.ip != null)
return false;
} else if (!ip.equals(other.ip))
return false;
if (privatePort != other.privatePort)
return false;
if (publicPort != other.publicPort)
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
}
|