Skip to content

Commit 76f2352

Browse files
committed
MatchingUtils: remove unused methods
1 parent 9949dfd commit 76f2352

File tree

1 file changed

+0
-83
lines changed

1 file changed

+0
-83
lines changed

scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/impl/MatchingUtils.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,11 @@
2929

3030
package org.scijava.ops.engine.matcher.impl;
3131

32-
import java.lang.reflect.ParameterizedType;
3332
import java.lang.reflect.Type;
3433
import java.lang.reflect.TypeVariable;
35-
import java.util.ArrayList;
36-
import java.util.Arrays;
3734
import java.util.HashMap;
38-
import java.util.HashSet;
39-
import java.util.Map;
4035

4136
import org.scijava.types.Any;
42-
import org.scijava.types.Nil;
4337
import org.scijava.types.Types;
4438
import org.scijava.types.Types.TypeVarInfo;
4539

@@ -137,81 +131,4 @@ static int checkGenericOutputsAssignability(Type[] froms, Type[] tos,
137131
}
138132
return -1;
139133
}
140-
141-
/**
142-
* Map type vars in specified type list to types using the specified map. In
143-
* doing so, type vars mapping to other type vars will not be followed but
144-
* just replaced.
145-
*
146-
* @param typesToMap
147-
* @param typeAssigns
148-
* @return a copy of {@code typesToMap} in which the {@link TypeVariable}s
149-
* (that are present in {@code typeAssigns}) are mapped to the
150-
* associated values within the {@code Map}.
151-
*/
152-
public static Type[] mapVarToTypes(Type[] typesToMap,
153-
Map<TypeVariable<?>, Type> typeAssigns)
154-
{
155-
return Arrays.stream(typesToMap).map(type -> Types.unroll(
156-
typeAssigns, type, false)).toArray(Type[]::new);
157-
}
158-
159-
/**
160-
* Gets the "useful" class information carries on the given object, which
161-
* depends on the actual type of the object.
162-
*/
163-
public static Class<?> getClass(final Object obj) {
164-
if (obj == null) return null;
165-
if (obj instanceof Nil) return getClass(((Nil<?>) obj).type());
166-
if (obj instanceof Class) return (Class<?>) obj;
167-
if (obj instanceof ParameterizedType)
168-
return (Class<?>) ((ParameterizedType) obj).getRawType();
169-
return obj.getClass();
170-
}
171-
172-
/**
173-
* Finds the levels of casting between {@code origin} and {@code dest}.
174-
* Returns 0 if dest and origin are the same. Returns -1 if dest is not
175-
* assignable from origin.
176-
*/
177-
public static int findCastLevels(final Class<?> dest, final Class<?> origin) {
178-
if (dest.equals(origin)) return 0;
179-
180-
int level = 1;
181-
Class<?> currType = origin;
182-
// BFS if dest is an interface
183-
if (dest.isInterface()) {
184-
final HashSet<String> seen = new HashSet<>();
185-
final ArrayList<Type> currIfaces = new ArrayList<>(Arrays.asList(currType
186-
.getGenericInterfaces()));
187-
do {
188-
final ArrayList<Type> nextIfaces = new ArrayList<>();
189-
for (final Type iface : currIfaces) {
190-
if (seen.contains(iface.getTypeName())) continue;
191-
192-
final Class<?> cls = getClass(iface);
193-
if (cls.equals(dest)) return level;
194-
seen.add(iface.getTypeName());
195-
nextIfaces.addAll(Arrays.asList(cls.getGenericInterfaces()));
196-
}
197-
currIfaces.clear();
198-
currIfaces.addAll(nextIfaces);
199-
if (currType.getSuperclass() != null) {
200-
currType = currType.getSuperclass();
201-
currIfaces.addAll(Arrays.asList(currType.getGenericInterfaces()));
202-
}
203-
level++;
204-
}
205-
while (!currIfaces.isEmpty() || currType.getSuperclass() != null);
206-
}
207-
// otherwise dest is a class, so search the list of ancestors
208-
else {
209-
while (currType.getSuperclass() != null) {
210-
currType = currType.getSuperclass();
211-
if (currType.equals(dest)) return level;
212-
level++;
213-
}
214-
}
215-
return -1;
216-
}
217134
}

0 commit comments

Comments
 (0)