summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2024-05-31 16:51:47 +0200
committer zaaarf <me@zaaarf.foo>2024-05-31 16:51:47 +0200
commitc48450085ba07655abc8b119629634f5ca43ebb9 (patch)
treeec860eb4cc4f81b53162cb798b4010d6b1de0f4f /src/main/java/ftbsc
parent9816a595b343da817648807fd468d3b3b8c2999e (diff)
fix: removed unnecessary reflection
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/lll/mapper/MapperProvider.java12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/main/java/ftbsc/lll/mapper/MapperProvider.java b/src/main/java/ftbsc/lll/mapper/MapperProvider.java
index ae7f760..5ac9178 100644
--- a/src/main/java/ftbsc/lll/mapper/MapperProvider.java
+++ b/src/main/java/ftbsc/lll/mapper/MapperProvider.java
@@ -8,7 +8,6 @@ import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
/**
* The main class of the mapper library. It loads all the
@@ -30,7 +29,7 @@ public class MapperProvider {
/**
* A {@link Set} containing all the loaded mapper classes.
*/
- private Set<Class<? extends IMappingFormat>> loadedMappers = null;
+ private Set<IMappingFormat> loadedMappers = null;
/**
* Loads the mapper classes into a {@link Set}.
@@ -38,7 +37,7 @@ public class MapperProvider {
private void loadMappers() {
this.loadedMappers = new HashSet<>();
for(IMappingFormat mapper: ServiceLoader.load(IMappingFormat.class))
- this.loadedMappers.add(mapper.getClass());
+ this.loadedMappers.add(mapper);
if(this.loadedMappers.isEmpty())
throw new RuntimeException("Something went wrong: no mapper types were loaded successfully!");
}
@@ -54,12 +53,7 @@ public class MapperProvider {
if(getInstance().loadedMappers == null)
getInstance().loadMappers();
return getInstance().loadedMappers.stream()
- .flatMap(clazz -> {
- try {
- return Stream.of(clazz.newInstance());
- } catch(ReflectiveOperationException ignored) {}
- return Stream.empty();
- }).filter(m -> m.claim(data))
+ .filter(m -> m.claim(data))
.max(Comparator.comparingInt(IMappingFormat::priority))
.orElseThrow(InvalidResourceException::new);
}