Skip to content

Commit bd01e9d

Browse files
committed
Narrow Collection returns to Set/List
1 parent f1fa478 commit bd01e9d

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎scijava/scijava-ops-api/src/main/java/org/scijava/ops/api/OpEnvironment.java‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
package org.scijava.ops.api;
3131

3232
import java.lang.reflect.Type;
33-
import java.util.Collection;
33+
import java.util.Set;
3434

3535
import org.scijava.types.Nil;
3636

@@ -721,15 +721,15 @@ default OpBuilder.Arity16 arity16(final String opName, final Hints hints) {
721721
/**
722722
* Creates an {@link OpInfo} from an {@link Class}.
723723
*
724-
* @param opClass
724+
* @param opClass the {@link Class} to derive the Op from
725725
* @return an {@link OpInfo} which can make instances of {@code opClass}
726726
*/
727727
OpInfo opify(Class<?> opClass);
728728

729729
/**
730730
* Creates an {@link OpInfo} from an {@link Class} with the given priority.
731731
*
732-
* @param opClass
732+
* @param opClass the {@link Class} to derive the Op from
733733
* @param priority - the assigned priority of the Op.
734734
* @param names - the name(s) of the Op
735735
* @return an {@link OpInfo} which can make instances of {@code opClass}
@@ -746,9 +746,9 @@ default OpBuilder.Arity16 arity16(final String opName, final Hints hints) {
746746
/**
747747
* Creates some {@link OpInfo}s from {@code o}
748748
* @param o the {@link Object} to create {@link OpInfo}s from
749-
* @return a {@link Collection} of {@link OpInfo}s
749+
* @return a {@link Set} of {@link OpInfo}s
750750
*/
751-
Collection<OpInfo> infosFrom(Object o);
751+
Set<OpInfo> infosFrom(Object o);
752752

753753
/**
754754
* Creates some {@link OpInfo}s from {@code o}
@@ -769,10 +769,10 @@ default void registerInfosFrom(Object o) {
769769
* Note that this method does not inherently provide <b>any</b> guarantees
770770
* pertaining to thread-safety; this API is provided purely for convenience.
771771
* Any calls to {@link OpEnvironment#op(String, Nil, Nil[], Nil)} that require
772-
* a specific {@Hints} should <b>not</b> use this method, instead opting for
772+
* a specific {@link Hints} should <b>not</b> use this method, instead opting for
773773
* {@link OpEnvironment#op(String, Nil, Nil[], Nil, Hints)}.
774774
*
775-
* @param hints
775+
* @param hints the {@link Hints} to be set as default
776776
*/
777777
void setDefaultHints(Hints hints);
778778

@@ -797,16 +797,16 @@ default void registerInfosFrom(Object o) {
797797
* Returns the descriptions for all Ops contained within this
798798
* {@link OpEnvironment}
799799
*
800-
* @return a {@link Collection} of descriptions
800+
* @return a {@link Set} of descriptions
801801
*/
802-
Collection<String> descriptions();
802+
Set<String> descriptions();
803803

804804
/**
805805
* Returns the descriptions for all Ops identifiable by a given name within
806806
* this {@link OpEnvironment}
807807
*
808-
* @return a {@link Collection} of descriptions
808+
* @return a {@link Set} of descriptions
809809
*/
810-
Collection<String> descriptions(String name);
810+
Set<String> descriptions(String name);
811811

812812
}

‎scijava/scijava-ops-engine/src/main/java/org/scijava/ops/engine/DefaultOpEnvironment.java‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,20 +318,20 @@ else if (o instanceof Iterable<?>) {
318318
}
319319

320320
@Override
321-
public Collection<OpInfo> infosFrom(Object o) {
321+
public Set<OpInfo> infosFrom(Object o) {
322322
return infoGenerators().parallelStream() //
323323
.filter(g -> g.canGenerateFrom(o)) //
324324
.flatMap(g -> g.generateInfosFrom(o).stream()) //
325325
.collect(Collectors.toSet());
326326
}
327327

328328
@Override
329-
public Collection<String> descriptions() {
329+
public Set<String> descriptions() {
330330
return descriptions(infos());
331331
}
332332

333333
@Override
334-
public Collection<String> descriptions(String name) {
334+
public Set<String> descriptions(String name) {
335335
return descriptions(infos(name));
336336
}
337337

@@ -344,14 +344,14 @@ public Collection<String> descriptions(String name) {
344344
* returning multiple instances of the same {@link OpInfo}. The duplicate
345345
* {@link OpInfo}s are created when Ops have multiple names.
346346
*
347-
* @param infos
348-
* @return a set of {@link String}s, one describing each {@link OpInfo} in
349-
* {@code infos}.
347+
* @param infos an {@link Iterable} of {@link OpInfo}s
348+
* @return a {@link Set} of {@link String}s, one describing each
349+
* {@link OpInfo} in {@code infos}.
350350
*/
351-
private List<String> descriptions(Iterable<OpInfo> infos) {
351+
private Set<String> descriptions(Iterable<OpInfo> infos) {
352352
return StreamSupport.stream(infos.spliterator(), true) //
353353
.map(OpInfo::toString) //
354-
.collect(Collectors.toList());
354+
.collect(Collectors.toSet());
355355
}
356356

357357
@SuppressWarnings("unchecked")
@@ -697,7 +697,7 @@ private synchronized void initOpDirectory() {
697697
* @param generators the {@link List} of {@link OpInfoGenerator}s
698698
* @return a {@link List} of {@link OpInfo}s
699699
*/
700-
private Collection<OpInfo> opsFromObject(Object o, List<OpInfoGenerator> generators) {
700+
private List<OpInfo> opsFromObject(Object o, List<OpInfoGenerator> generators) {
701701
return generators.stream() //
702702
.filter(g -> g.canGenerateFrom(o)) //
703703
.flatMap(g -> g.generateInfosFrom(o).stream()) //

0 commit comments

Comments
 (0)