Skip to content

Commit 8c13ab0

Browse files
committed
Add/remove methods in shim types
1 parent ba4cdf2 commit 8c13ab0

2 files changed

Lines changed: 23 additions & 54 deletions

File tree

src/main/java/nextflow/script/types/shim/List.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ public interface List<E> extends Iterable<E> {
3535
Collates the list into a list of sub-lists of length `size`. If `keepRemainder` is `true`, any remaining elements are included as a partial sub-list, otherwise they are excluded.
3636
""")
3737
List<List<E>> collate(int size, boolean keepRemainder);
38+
List<List<E>> collate(int size);
3839

3940
@Description("""
4041
Collates the list into a list of sub-lists of length `size`, stepping through the list `step` elements for each sub-list. If `keepRemainder` is `true`, any remaining elements are included as a partial sub-list, otherwise they are excluded.
4142
""")
4243
List<List<E>> collate(int size, int step, boolean keepRemainder);
44+
List<List<E>> collate(int size, int step);
4345

4446
@Description("""
4547
Returns the first value in the list that satisfies the given condition.

src/main/java/nextflow/script/types/shim/Path.java

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ public interface Path {
3333

3434
// file attributes
3535

36-
@Description("""
37-
Returns `true` if the file exists.
38-
""")
39-
boolean exists();
40-
4136
@Constant("baseName")
4237
@Description("""
4338
Gets the file name without its extension, e.g. `/some/path/file.tar.gz` -> `file.tar`.
@@ -56,12 +51,6 @@ public interface Path {
5651
""")
5752
String getName();
5853

59-
@Constant("simpleName")
60-
@Description("""
61-
Gets the file name without any extension, e.g. `/some/path/file.tar.gz` -> `file`.
62-
""")
63-
String getSimpleName();
64-
6554
@Constant("parent")
6655
@Description("""
6756
Gets the file parent path, e.g. `/some/path/file.txt` -> `/some/path`.
@@ -74,6 +63,17 @@ public interface Path {
7463
""")
7564
String getScheme();
7665

66+
@Constant("simpleName")
67+
@Description("""
68+
Gets the file name without any extension, e.g. `/some/path/file.tar.gz` -> `file`.
69+
""")
70+
String getSimpleName();
71+
72+
@Description("""
73+
Returns `true` if the file exists.
74+
""")
75+
boolean exists();
76+
7777
@Description("""
7878
Returns `true` if the file is a directory.
7979
""")
@@ -131,22 +131,11 @@ Returns the file last modified timestamp in Unix time (i.e. milliseconds since J
131131

132132
// reading
133133

134-
@Description("""
135-
Iterates over the file, applying the specified closure to each byte.
136-
""")
137-
void eachByte(Consumer<Byte> action);
138-
139134
@Description("""
140135
Iterates over the file, applying the specified closure to each line.
141136
""")
142137
void eachLine(Consumer<String> action);
143138

144-
@Constant("bytes")
145-
@Description("""
146-
Returns the file content as a byte array.
147-
""")
148-
byte[] getBytes();
149-
150139
@Constant("text")
151140
@Description("""
152141
Returns the file content as a string.
@@ -165,11 +154,6 @@ Returns the file last modified timestamp in Unix time (i.e. milliseconds since J
165154
""")
166155
void append(String text);
167156

168-
@Description("""
169-
Writes a byte array to a file. Equivalent to setting the `bytes` property.
170-
""")
171-
void setBytes(byte[] bytes);
172-
173157
@Description("""
174158
Writes text to a file. Equivalent to setting the `text` property.
175159
""")
@@ -202,16 +186,6 @@ Returns the file last modified timestamp in Unix time (i.e. milliseconds since J
202186
""")
203187
String getPermissions();
204188

205-
@Description("""
206-
Returns the first-level elements (files and directories) of a directory as a list of strings.
207-
""")
208-
List<String> list();
209-
210-
@Description("""
211-
Returns the first-level elements (files and directories) of a directory as a list of Paths.
212-
""")
213-
List<Path> listFiles();
214-
215189
@Description("""
216190
Creates a directory at the given path, returning `true` if the directory is created successfully, and `false` otherwise.
217191
""")
@@ -247,35 +221,28 @@ Returns the file last modified timestamp in Unix time (i.e. milliseconds since J
247221
""")
248222
boolean setPermissions(int owner, int group, int other);
249223

250-
@Description("""
251-
Iterates through first-level directories only.
252-
""")
253-
void eachDir(Consumer<Path> action);
254-
255-
@Description("""
256-
Iterates through directories whose names match the given filter.
257-
""")
258-
void eachDirMatch(String nameFilter, Consumer<Path> action);
224+
// listing and traversing directories
259225

260226
@Description("""
261-
Iterates through directories depth-first (regular files are ignored).
227+
Iterates through first-level files and directories.
262228
""")
263-
void eachDirRecurse(Consumer<Path> action);
229+
void eachFile(Consumer<Path> action);
264230

265231
@Description("""
266-
Iterates through first-level files and directories.
232+
Iterates through files and directories depth-first.
267233
""")
268-
void eachFile(Consumer<Path> action);
234+
void eachFileRecurse(Consumer<Path> action);
269235

270236
@Description("""
271-
Iterates through files and directories whose names match the given filter.
237+
Returns the first-level elements (files and directories) in a directory.
272238
""")
273-
void eachFileMatch(String nameFilter, Consumer<Path> action);
239+
List<Path> listDirectory();
274240

241+
@Deprecated
275242
@Description("""
276-
Iterates through files and directories depth-first.
243+
Returns the first-level elements (files and directories) in a directory.
277244
""")
278-
void eachFileRecurse(Consumer<Path> action);
245+
List<Path> listFiles();
279246

280247
// splitting
281248

0 commit comments

Comments
 (0)