Skip to content

Commit

Permalink
Polish "Add optional 'command' to Docker compose service"
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Sep 15, 2023
1 parent 85a17e7 commit ed0e1c8
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ public final class DockerService implements Consumer<ComposeService.Builder> {

private final int[] ports;

private DockerService(DockerService.Builder builder) {
private DockerService(Builder builder) {
this.image = builder.image;
this.imageTag = builder.imageTag;
this.website = builder.website;
this.command = builder.command;
this.ports = builder.ports.stream().mapToInt(Number::intValue).toArray();
this.ports = builder.ports.stream().mapToInt(Integer::intValue).toArray();
}

/**
* Return a new builder using the specified image and optional tag.
* Create a new builder using the specified image and optional tag.
* @param imageAndTag the image (and optional tag) to use for the service
* @return the new builder instance.
*/
Expand Down Expand Up @@ -85,7 +85,7 @@ public String getWebsite() {
}

/**
* Return the command to use to override the default command (optional).
* Return the command to use, if any.
* @return the command
*/
public String getCommand() {
Expand Down Expand Up @@ -130,38 +130,38 @@ protected Builder(String imageAndTag) {
image(split[0]).imageTag(tag);
}

public DockerService.Builder image(String image) {
public Builder image(String image) {
this.image = image;
return this;
}

public DockerService.Builder imageTag(String imageTag) {
public Builder imageTag(String imageTag) {
this.imageTag = imageTag;
return this;
}

public DockerService.Builder website(String website) {
public Builder website(String website) {
this.website = website;
return this;
}

public DockerService.Builder command(String command) {
public Builder command(String command) {
this.command = command;
return this;
}

public DockerService.Builder ports(Collection<Integer> ports) {
public Builder ports(Collection<Integer> ports) {
this.ports.addAll(ports);
return this;
}

public DockerService.Builder ports(int... ports) {
public Builder ports(int... ports) {
return ports(Arrays.stream(ports).boxed().toList());
}

/**
* Builds the {@link DockerService} instance.
* @return the built instance
* Build a {@link DockerService} with the current state of this builder.
* @return a {@link DockerService}
*/
public DockerService build() {
return new DockerService(this);
Expand Down

0 comments on commit ed0e1c8

Please sign in to comment.