1 | package com.github.dakusui.actionunit.actions.cmd.unix; | |
2 | ||
3 | import com.github.dakusui.actionunit.actions.cmd.Commander; | |
4 | import com.github.dakusui.actionunit.actions.cmd.CommanderConfig; | |
5 | import com.github.dakusui.actionunit.core.Context; | |
6 | ||
7 | import java.io.File; | |
8 | import java.util.Objects; | |
9 | import java.util.function.Consumer; | |
10 | import java.util.function.Function; | |
11 | ||
12 | import static com.github.dakusui.actionunit.utils.Checks.requireState; | |
13 | import static java.lang.String.format; | |
14 | import static java.util.Objects.requireNonNull; | |
15 | ||
16 | public class Cat extends Commander<Cat> { | |
17 | /** | |
18 | * A tag for here-document | |
19 | */ | |
20 | private String tag; | |
21 | ||
22 | public Cat(CommanderConfig config) { | |
23 | super(config, "cat"); | |
24 | this.tag = null; | |
25 | commandName("cat"); | |
26 | } | |
27 | ||
28 | public Cat hereDocument(String tag, Consumer<Cat> b) { | |
29 | this.beginHereDocument(tag); | |
30 |
1
1. hereDocument : removed call to java/util/function/Consumer::accept → KILLED |
b.accept(this); |
31 |
1
1. hereDocument : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::hereDocument → KILLED |
return this.newLine().endHereDocument(); |
32 | } | |
33 | ||
34 | public Cat beginHereDocument(String tag) { | |
35 | requireState(Objects::isNull, this.tag); | |
36 | this.tag = requireNonNull(tag); | |
37 |
1
1. beginHereDocument : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::beginHereDocument → KILLED |
return this.append(" ").append("<<").append(tag).newLine(); |
38 | } | |
39 | ||
40 | /** | |
41 | * This method should only be used inside a here-document. | |
42 | * | |
43 | * @return This object. | |
44 | */ | |
45 | public Cat newLine() { | |
46 | requireState(Objects::nonNull, this.tag); | |
47 |
1
1. newLine : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::newLine → KILLED |
return this.append(format("%n")); |
48 | } | |
49 | ||
50 | public Cat write(String text) { | |
51 | requireState(Objects::nonNull, this.tag); | |
52 |
1
1. write : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::write → KILLED |
return this.append(requireNonNull(text)); |
53 | } | |
54 | ||
55 | public Cat writeln(String text) { | |
56 | requireState(Objects::nonNull, this.tag); | |
57 |
1
1. writeln : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::writeln → KILLED |
return this.append(requireNonNull(text)).newLine(); |
58 | } | |
59 | ||
60 | public Cat endHereDocument() { | |
61 | requireState(Objects::nonNull, this.tag); | |
62 |
1
1. endHereDocument : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::endHereDocument → KILLED |
return this.append(this.tag); |
63 | } | |
64 | ||
65 | public Cat lineNumber() { | |
66 |
1
1. lineNumber : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::lineNumber → KILLED |
return this.append(" ").append("-n"); |
67 | } | |
68 | ||
69 | public Cat file(File file) { | |
70 |
1
1. file : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::file → KILLED |
return this.file(requireNonNull(file).getAbsolutePath()); |
71 | } | |
72 | ||
73 | public Cat file(String fileName) { | |
74 |
1
1. file : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::file → KILLED |
return add(fileName); |
75 | } | |
76 | ||
77 | public Cat file(Function<Context, String> fileName) { | |
78 |
1
1. file : replaced return value with null for com/github/dakusui/actionunit/actions/cmd/unix/Cat::file → KILLED |
return add(fileName); |
79 | } | |
80 | } | |
Mutations | ||
30 |
1.1 |
|
31 |
1.1 |
|
37 |
1.1 |
|
47 |
1.1 |
|
52 |
1.1 |
|
57 |
1.1 |
|
62 |
1.1 |
|
66 |
1.1 |
|
70 |
1.1 |
|
74 |
1.1 |
|
78 |
1.1 |