Skip to content

Commit c8d195a

Browse files
gselzerctrueden
authored andcommitted
Clean OpEnvironment
1 parent f9cbd53 commit c8d195a

3 files changed

Lines changed: 4 additions & 73 deletions

File tree

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -128,31 +128,6 @@ InfoChain infoChain(final String opName, final Nil<?> specialType,
128128
InfoChain infoChain(final String opName, final Nil<?> specialType,
129129
final Nil<?>[] inTypes, final Nil<?> outType, Hints hints);
130130

131-
/**
132-
* Returns an Op fitting the provided arguments. NB implementations of this
133-
* method likely depend on the {@link Hints} set by
134-
* {@link OpEnvironment#setDefaultHints(Hints)}, which provides no guarantee of
135-
* thread-safety. Users interested in parallel Op matching should consider
136-
* using {@link OpEnvironment#opFromInfo(String, Nil, Hints)} instead.
137-
*
138-
* @param <T> the {@link Type} of the Op
139-
* @param info the {@link OpInfo}
140-
* @param specialType the generic {@link Type} of the Op
141-
* @return an instance of an Op aligning with the search parameters
142-
*/
143-
<T> T opFromInfo(OpInfo info, Nil<T> specialType);
144-
145-
/**
146-
* Returns an Op fitting the provided arguments.
147-
*
148-
* @param <T> the {@link Type} of the Op
149-
* @param info the {@link OpInfo}
150-
* @param specialType the generic {@link Type} of the Op
151-
* @param hints the {@link Hints} that should guide this matching call
152-
* @return an instance of an Op aligning with the search parameters
153-
*/
154-
<T> T opFromInfo(OpInfo info, Nil<T> specialType, Hints hints);
155-
156131
<T> T opFromInfoChain(InfoChain chain, Nil<T> specialType);
157132

158133
/**

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,24 +238,6 @@ public InfoChain infoChain(String opName, Nil<?> specialType,
238238
throw new IllegalArgumentException(e);
239239
}
240240
}
241-
242-
@Override
243-
public <T> T opFromInfo(final OpInfo info, final Nil<T> specialType, Hints hints) {
244-
try {
245-
return findOp(info, specialType, hints).asOpType();
246-
} catch (OpMatchingException e) {
247-
throw new IllegalArgumentException(e);
248-
}
249-
}
250-
251-
@Override
252-
public <T> T opFromInfo(final OpInfo info, final Nil<T> specialType) {
253-
try {
254-
return findOp(info, specialType, getDefaultHints()).asOpType();
255-
} catch (OpMatchingException e) {
256-
throw new IllegalArgumentException(e);
257-
}
258-
}
259241

260242
@Override
261243
public InfoChain chainFromInfo(OpInfo info, Nil<?> specialType) {
@@ -496,8 +478,8 @@ private OpInstance<?> instantiateOp(final OpCandidate candidate, Hints hints)
496478
/**
497479
* Wraps the matched op into an {@link Op} that knows its generic typing.
498480
*
499-
* @param op - the op to wrap.
500-
* @param opInfo - from which we determine the {@link Type} of the {@code Op}
481+
* @param instance - the {@link OpInstance} to wrap.
482+
* @param hints - the {@link Hints} used to create the {@link OpInstance}
501483
*
502484
* @return an {@link Op} wrapping of op.
503485
*/
@@ -559,6 +541,7 @@ private List<RichOp<?>> resolveOpDependencies(OpCandidate candidate, Hints hints
559541
return resolveOpDependencies(candidate.opInfo(), candidate.typeVarAssigns(), hints);
560542
}
561543

544+
@SuppressWarnings("rawtypes")
562545
private synchronized void initWrappers() {
563546
if (wrappers != null) return;
564547
wrappers = new HashMap<>();
@@ -769,7 +752,7 @@ private OpRef inferOpRef(OpDependencyMember<?> dependency,
769752
*
770753
* Input and output types will be inferred by looking at the signature of the
771754
* functional method of the specified type. Also see
772-
* {@link ParameterStructs#findFunctionalMethodTypes(Type)}.
755+
* {@link FunctionalParameters#findFunctionalMethodTypes(Type)}.
773756
*
774757
* @param type
775758
* @param name

scijava/scijava-ops-engine/src/main/java/org/scijava/ops/engine/simplify/SimplificationUtils.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.lang.reflect.ParameterizedType;
99
import java.lang.reflect.Type;
1010
import java.lang.reflect.TypeVariable;
11-
import java.util.ArrayList;
1211
import java.util.Arrays;
1312
import java.util.HashMap;
1413
import java.util.List;
@@ -21,13 +20,11 @@
2120
import org.scijava.function.Computers;
2221
import org.scijava.function.Container;
2322
import org.scijava.function.Mutable;
24-
import org.scijava.ops.api.InfoChain;
2523
import org.scijava.ops.api.OpEnvironment;
2624
import org.scijava.ops.api.OpInfo;
2725
import org.scijava.ops.api.OpRef;
2826
import org.scijava.ops.api.OpUtils;
2927
import org.scijava.ops.engine.util.internal.AnnotationUtils;
30-
import org.scijava.types.Nil;
3128
import org.scijava.types.Types;
3229
import org.scijava.types.inference.GenericAssignability;
3330
import org.scijava.types.inference.InterfaceInference;
@@ -162,30 +159,6 @@ public static Type resolveMutatorTypeArgs(Type inferFrom, Type mutatorInferFrom,
162159
return Types.mapVarToTypes(unresolvedType, map);
163160
}
164161

165-
/**
166-
* Finds required mutators (i.e. simplifier or focuser).
167-
*
168-
* @param mutatorInfos - the {@link OpInfo}s for which Ops are needed
169-
* @return a set of {@code Op}s, instantiated from {@code mutatorInfo}s, that
170-
* satisfy the prescribed input/output types.
171-
*/
172-
public static List<Function<?, ?>> findArgMutators(List<InfoChain> mutatorInfos)
173-
{
174-
List<Function<?, ?>> mutators = new ArrayList<>();
175-
for(int i = 0; i < mutatorInfos.size(); i++) {
176-
Function<?, ?> mutator = (Function<?, ?>) mutatorInfos.get(i).op().op();
177-
mutators.add(mutator);
178-
}
179-
return mutators;
180-
}
181-
182-
public static Function<?, ?> findArgMutator(OpEnvironment env, OpInfo mutatorInfo, Type originalInput, Type mutatedInput){
183-
Type opType = Types.parameterize(Function.class, new Type[] {originalInput, mutatedInput});
184-
Function<?, ?> mutator = (Function<?, ?>) env.opFromInfo(mutatorInfo,
185-
Nil.of(opType));
186-
return mutator;
187-
}
188-
189162
/**
190163
* Uses Google Guava to generate a list of permutations of each available
191164
* simplification possibility

0 commit comments

Comments
 (0)