[FIX] Лишний if.

This commit is contained in:
Zaxar163 2020-02-10 19:35:48 +01:00
parent adefda970e
commit dab4b21ae7
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B

View file

@ -14,6 +14,7 @@
import pro.gravit.launcher.LauncherInject; import pro.gravit.launcher.LauncherInject;
import pro.gravit.launcher.LauncherInjectionConstructor; import pro.gravit.launcher.LauncherInjectionConstructor;
@SuppressWarnings("rawtypes")
public class InjectClassAcceptor implements MainBuildTask.ASMTransformer { public class InjectClassAcceptor implements MainBuildTask.ASMTransformer {
private final Map<String, Object> values; private final Map<String, Object> values;
@ -139,6 +140,7 @@ public void visit(final String name, final Object value) {
ret.add(new InsnNode(Opcodes.I2C)); ret.add(new InsnNode(Opcodes.I2C));
return ret; return ret;
}); });
serializers.put(Enum.class, (Serializer<Enum>) value -> NodeUtils.makeValueEnumGetter(value));
} }
private static Serializer<?> serializerClass(int opcode) { private static Serializer<?> serializerClass(int opcode) {
@ -159,7 +161,7 @@ private interface Serializer<T> {
InsnList serialize(T value); InsnList serialize(T value);
} }
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings("unchecked")
private static InsnList serializeValue(Object value) { private static InsnList serializeValue(Object value) {
if (value == null) { if (value == null) {
InsnList insnList = new InsnList(); InsnList insnList = new InsnList();
@ -171,8 +173,6 @@ private static InsnList serializeValue(Object value) {
insnList.add(new LdcInsnNode(value)); insnList.add(new LdcInsnNode(value));
return insnList; return insnList;
} }
if (Enum.class.isInstance(value))
return NodeUtils.makeValueEnumGetter((Enum)value);
for (Map.Entry<Class<?>, Serializer<?>> serializerEntry : serializers.entrySet()) { for (Map.Entry<Class<?>, Serializer<?>> serializerEntry : serializers.entrySet()) {
if (serializerEntry.getKey().isInstance(value)) { if (serializerEntry.getKey().isInstance(value)) {
return ((Serializer) serializerEntry.getValue()).serialize(value); return ((Serializer) serializerEntry.getValue()).serialize(value);
@ -182,9 +182,7 @@ private static InsnList serializeValue(Object value) {
value.getClass())); value.getClass()));
} }
@SuppressWarnings("rawtypes")
private static class ListSerializer implements Serializer<List> { private static class ListSerializer implements Serializer<List> {
@Override @Override
public InsnList serialize(List value) { public InsnList serialize(List value) {
InsnList insnList = new InsnList(); InsnList insnList = new InsnList();
@ -204,9 +202,7 @@ public InsnList serialize(List value) {
} }
} }
@SuppressWarnings("rawtypes")
private static class MapSerializer implements Serializer<Map> { private static class MapSerializer implements Serializer<Map> {
@Override @Override
public InsnList serialize(Map value) { public InsnList serialize(Map value) {
InsnList insnList = new InsnList(); InsnList insnList = new InsnList();