Skip to content

Commit 1896b15

Browse files
committed
Make OperaOptions fluent
1 parent 7592347 commit 1896b15

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

java/client/src/org/openqa/selenium/opera/OperaOptions.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ public OperaOptions() {
8181
*
8282
* @param path Path to Opera executable.
8383
*/
84-
public void setBinary(File path) {
84+
public OperaOptions setBinary(File path) {
8585
binary = checkNotNull(path).getPath();
86+
return this;
8687
}
8788

8889
/**
@@ -92,16 +93,18 @@ public void setBinary(File path) {
9293
*
9394
* @param path Path to Opera executable.
9495
*/
95-
public void setBinary(String path) {
96+
public OperaOptions setBinary(String path) {
9697
binary = checkNotNull(path);
98+
return this;
9799
}
98100

99101
/**
100102
* @param arguments The arguments to use when starting Opera.
101103
* @see #addArguments(java.util.List)
102104
*/
103-
public void addArguments(String... arguments) {
105+
public OperaOptions addArguments(String... arguments) {
104106
addArguments(ImmutableList.copyOf(arguments));
107+
return this;
105108
}
106109

107110
/**
@@ -119,16 +122,18 @@ public void addArguments(String... arguments) {
119122
*
120123
* @param arguments The arguments to use when starting Opera.
121124
*/
122-
public void addArguments(List<String> arguments) {
125+
public OperaOptions addArguments(List<String> arguments) {
123126
args.addAll(arguments);
127+
return this;
124128
}
125129

126130
/**
127131
* @param paths Paths to the extensions to install.
128132
* @see #addExtensions(java.util.List)
129133
*/
130-
public void addExtensions(File... paths) {
134+
public OperaOptions addExtensions(File... paths) {
131135
addExtensions(ImmutableList.copyOf(paths));
136+
return this;
132137
}
133138

134139
/**
@@ -137,22 +142,24 @@ public void addExtensions(File... paths) {
137142
*
138143
* @param paths Paths to the extensions to install.
139144
*/
140-
public void addExtensions(List<File> paths) {
145+
public OperaOptions addExtensions(List<File> paths) {
141146
for (File path : paths) {
142147
checkNotNull(path);
143148
checkArgument(path.exists(), "%s does not exist", path.getAbsolutePath());
144149
checkArgument(!path.isDirectory(), "%s is a directory",
145150
path.getAbsolutePath());
146151
}
147152
extensionFiles.addAll(paths);
153+
return this;
148154
}
149155

150156
/**
151157
* @param encoded Base64 encoded data of the extensions to install.
152158
* @see #addEncodedExtensions(java.util.List)
153159
*/
154-
public void addEncodedExtensions(String... encoded) {
160+
public OperaOptions addEncodedExtensions(String... encoded) {
155161
addEncodedExtensions(ImmutableList.copyOf(encoded));
162+
return this;
156163
}
157164

158165
/**
@@ -161,11 +168,12 @@ public void addEncodedExtensions(String... encoded) {
161168
*
162169
* @param encoded Base64 encoded data of the extensions to install.
163170
*/
164-
public void addEncodedExtensions(List<String> encoded) {
171+
public OperaOptions addEncodedExtensions(List<String> encoded) {
165172
for (String extension : encoded) {
166173
checkNotNull(extension);
167174
}
168175
extensions.addAll(encoded);
176+
return this;
169177
}
170178

171179
/**
@@ -176,8 +184,9 @@ public void addEncodedExtensions(List<String> encoded) {
176184
* @param value Value of the experimental option, which must be convertible
177185
* to JSON.
178186
*/
179-
public void setExperimentalOption(String name, Object value) {
187+
public OperaOptions setExperimentalOption(String name, Object value) {
180188
experimentalOptions.put(checkNotNull(name), value);
189+
return this;
181190
}
182191

183192
/**

0 commit comments

Comments
 (0)