forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveImagesCmdImpl.java
More file actions
63 lines (48 loc) · 1.68 KB
/
Copy pathSaveImagesCmdImpl.java
File metadata and controls
63 lines (48 loc) · 1.68 KB
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
package com.github.dockerjava.core.command;
import com.github.dockerjava.api.command.SaveImagesCmd;
import com.github.dockerjava.api.exception.NotFoundException;
import com.google.common.collect.ImmutableList;
import javax.annotation.Nonnull;
import java.io.InputStream;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
public class SaveImagesCmdImpl extends AbstrDockerCmd<SaveImagesCmd, InputStream> implements SaveImagesCmd {
private static class TaggedImageImpl implements TaggedImage {
private final String name;
private final String tag;
private TaggedImageImpl(String name, String tag) {
checkNotNull(name, "image name was not specified");
checkNotNull(tag, "image tag was not specified");
this.name = name;
this.tag = tag;
}
@Override
public String asString() {
return name + ":" + tag;
}
@Override
public String toString() {
return asString();
}
}
private final ImmutableList.Builder<TaggedImage> taggedImages = ImmutableList.builder();
public SaveImagesCmdImpl(final SaveImagesCmd.Exec exec) {
super(exec);
}
@Override
public SaveImagesCmd withImage(@Nonnull final String name, @Nonnull final String tag) {
taggedImages.add(new TaggedImageImpl(name, tag));
return this;
}
@Override
public List<TaggedImage> getImages() {
return taggedImages.build();
}
/**
* @throws NotFoundException No such images
*/
@Override
public InputStream exec() throws NotFoundException {
return super.exec();
}
}