-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ben Sherman <[email protected]>
- Loading branch information
1 parent
18b5c58
commit 69a4ccc
Showing
11 changed files
with
389 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import java.util.function.BiFunction; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
An iterable is a common interface for collections that support iteration. | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#iterable) | ||
""") | ||
public interface Iterable<E> { | ||
|
||
@Description(""" | ||
Returns `true` if any value in the iterable satisfies the given condition. | ||
""") | ||
boolean any(Predicate<E> predicate); | ||
|
||
@Description(""" | ||
Returns a new iterable with each value transformed by the given closure. | ||
""") | ||
<R> Iterable<R> collect(Function<E,R> mapper); | ||
|
||
@Description(""" | ||
Invoke the given closure for each value in the iterable. | ||
""") | ||
void each(Consumer<E> action); | ||
|
||
@Description(""" | ||
Returns `true` if every value in the iterable satisfies the given condition. | ||
""") | ||
boolean every(Predicate<E> predicate); | ||
|
||
@Description(""" | ||
Returns the values in the iterable that satisfy the given condition. | ||
""") | ||
Iterable<E> findAll(Predicate<E> predicate); | ||
|
||
@Description(""" | ||
Returns a new iterable with each value transformed by the given closure. | ||
""") | ||
<R> R inject(R initialValue, BiFunction<R,E,R> accumulator); | ||
|
||
@Description(""" | ||
Returns the number of values in the iterable. | ||
""") | ||
int size(); | ||
|
||
@Description(""" | ||
Returns a sorted list of the iterable's values. | ||
""") | ||
List<E> sort(); | ||
|
||
@Description(""" | ||
Returns the sum of the values in the iterable. The values should support the `+` operator. | ||
""") | ||
E sum(); | ||
|
||
@Description(""" | ||
Converts the iterable to a set. Duplicate values are excluded. | ||
""") | ||
Set<E> toSet(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
A list is an unordered collection of elements. | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#list) | ||
""") | ||
@ShimType(java.util.List.class) | ||
public interface List<E> extends Iterable<E> { | ||
|
||
@Description(""" | ||
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. | ||
""") | ||
List<?> collate(int size, int step, boolean keepRemainder); | ||
|
||
@Description(""" | ||
Returns the first element in the list. Raises an error if the list is empty. | ||
""") | ||
E first(); | ||
|
||
@Description(""" | ||
Returns the list of integers from 0 to *n - 1*, where *n* is the number of elements in the list. | ||
""") | ||
List<Integer> getIndices(); | ||
|
||
@Description(""" | ||
Returns a list of 2-tuples corresponding to the value and index of each element in the list. | ||
""") | ||
List withIndex(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import java.util.function.BiConsumer; | ||
|
||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
A map "maps" keys to values. Each key can map to at most one value -- a map cannot contain duplicate keys. | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#map) | ||
""") | ||
@ShimType(java.util.Map.class) | ||
public interface Map<K,V> { | ||
|
||
@Description(""" | ||
Invoke the given closure for each key-value pair in the map. The closure should accept two parameters corresponding to the key and value of an entry. | ||
""") | ||
void each(BiConsumer<K,V> action); | ||
|
||
@Description(""" | ||
Returns a set of the key-value pairs in the map. | ||
""") | ||
Set<Entry<K,V>> entrySet(); | ||
|
||
@Description(""" | ||
A map entry is a key-value pair. | ||
""") | ||
interface Entry<K,V> { | ||
K getKey(); | ||
V getValue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import nextflow.script.dsl.Constant; | ||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
A Path is a handle for hierarchichal paths such as local files and directories, HTTP/FTP URLs, and object storage paths (e.g. Amazon S3). | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#path) | ||
""") | ||
@ShimType(java.nio.file.Path.class) | ||
public interface Path { | ||
|
||
@Constant("text") | ||
@Description(""" | ||
Returns the file content as a string value. | ||
""") | ||
String getText(); | ||
|
||
@Description(""" | ||
Reads the file line by line and returns the content as a list of strings. | ||
""") | ||
List<String> readLines(); | ||
|
||
@Description(""" | ||
Splits a CSV file into a list of records. | ||
""") | ||
List<?> splitCsv(); | ||
|
||
@Description(""" | ||
Splits a text file into a list of lines. | ||
""") | ||
List<String> splitText(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
A set is an unordered collection that cannot contain duplicate elements. | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#set) | ||
""") | ||
@ShimType(java.util.Set.class) | ||
public interface Set<E> extends Iterable<E> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
public @interface ShimType { | ||
Class value(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2013-2024, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package nextflow.script.types; | ||
|
||
import nextflow.script.dsl.Description; | ||
|
||
@Description(""" | ||
A string is an immutable array of characters. | ||
[Read more](https://nextflow.io/docs/latest/reference/stdlib.html#string) | ||
""") | ||
@ShimType(java.lang.String.class) | ||
public interface String { | ||
|
||
@Description(""" | ||
Parses the string into an integer. | ||
""") | ||
Integer toInteger(); | ||
|
||
@Description(""" | ||
Splits the string into a list of substrings using the given delimiters. Each character in the delimiter string is treated as a separate delimiter. | ||
""") | ||
List<String> tokenize(String delimiters); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.