-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Port class instead of strings (#511)
- Loading branch information
Showing
22 changed files
with
210 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/Port.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2018 Google LLC. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.jib.configuration; | ||
|
||
import java.util.Objects; | ||
|
||
/** Holds port number and protocol for an exposed port. */ | ||
public class Port { | ||
|
||
/** Represents the protocol portion of the port. */ | ||
public enum Protocol { | ||
TCP("tcp"), | ||
UDP("udp"); | ||
|
||
private final String stringRepresentation; | ||
|
||
Protocol(String stringRepresentation) { | ||
this.stringRepresentation = stringRepresentation; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return stringRepresentation; | ||
} | ||
} | ||
|
||
private final int port; | ||
private final Protocol protocol; | ||
|
||
public Port(int port, Protocol protocol) { | ||
this.port = port; | ||
this.protocol = protocol; | ||
} | ||
|
||
public int getPort() { | ||
return port; | ||
} | ||
|
||
public Protocol getProtocol() { | ||
return protocol; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
if (other == null || !(other instanceof Port)) { | ||
return false; | ||
} | ||
Port otherPort = (Port) other; | ||
return port == otherPort.port && protocol == otherPort.protocol; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(port, protocol); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return port + "/" + protocol; | ||
} | ||
} |
87 changes: 0 additions & 87 deletions
87
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/PortsWithProtocol.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.