mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-21 15:50:40 +00:00
reformat + imports
This commit is contained in:
@@ -22,6 +22,7 @@ public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolde
|
||||
BiomeProvider getBiomeProviderBuilder();
|
||||
|
||||
<T> CheckedRegistry<T> getOrCreateRegistry(Type clazz);
|
||||
|
||||
default <T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz) {
|
||||
return getOrCreateRegistry((Type) clazz);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.dfsek.terra.api.event;
|
||||
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
import com.dfsek.terra.api.event.functional.EventContext;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
/**
|
||||
* Manages event registration and triggering.
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Fired when a pack is searched for {@link Configuration}s.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.api.event.functional;
|
||||
|
||||
import com.dfsek.terra.api.event.EventManager;
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -14,7 +14,8 @@ public class Context {
|
||||
}
|
||||
|
||||
public Context put(Properties properties) {
|
||||
if(map.containsKey(properties.getClass())) throw new IllegalArgumentException("Property for class " + properties.getClass().getCanonicalName() + " already registered.");
|
||||
if(map.containsKey(properties.getClass()))
|
||||
throw new IllegalArgumentException("Property for class " + properties.getClass().getCanonicalName() + " already registered.");
|
||||
map.put(properties.getClass(), properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class BinaryColumn {
|
||||
public BinaryColumn(int minY, int maxY) {
|
||||
this.minY = minY;
|
||||
if(maxY <= minY) throw new IllegalArgumentException("Max y must be greater than min y");
|
||||
this.data = new boolean[maxY-minY];
|
||||
this.data = new boolean[maxY - minY];
|
||||
}
|
||||
|
||||
public void set(int y) {
|
||||
|
||||
@@ -41,18 +41,18 @@ public final class ReflectionUtil {
|
||||
}
|
||||
|
||||
public static Class<?> getRawType(Type type) {
|
||||
if (type instanceof Class<?>) {
|
||||
if(type instanceof Class<?>) {
|
||||
return (Class<?>) type;
|
||||
} else if (type instanceof ParameterizedType) {
|
||||
} else if(type instanceof ParameterizedType) {
|
||||
ParameterizedType parameterizedType = (ParameterizedType) type;
|
||||
Type rawType = parameterizedType.getRawType();
|
||||
return (Class<?>) rawType;
|
||||
} else if (type instanceof GenericArrayType) {
|
||||
Type componentType = ((GenericArrayType)type).getGenericComponentType();
|
||||
} else if(type instanceof GenericArrayType) {
|
||||
Type componentType = ((GenericArrayType) type).getGenericComponentType();
|
||||
return Array.newInstance(getRawType(componentType), 0).getClass();
|
||||
} else if (type instanceof TypeVariable) {
|
||||
} else if(type instanceof TypeVariable) {
|
||||
return Object.class;
|
||||
} else if (type instanceof WildcardType) {
|
||||
} else if(type instanceof WildcardType) {
|
||||
return getRawType(((WildcardType) type).getUpperBounds()[0]);
|
||||
} else {
|
||||
String className = type == null ? "null" : type.getClass().getName();
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package com.dfsek.terra.api.util.reflection;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.lang.reflect.AnnotatedParameterizedType;
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.WildcardType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -38,40 +44,6 @@ public class TypeKey<T> {
|
||||
return parameterized.getAnnotatedActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw (non-generic) type for this type.
|
||||
*/
|
||||
public final Class<? super T> getRawType() {
|
||||
return rawType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets underlying {@code Type} instance.
|
||||
*/
|
||||
public final Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AnnotatedType getAnnotatedType() {
|
||||
return annotatedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
return o instanceof TypeKey<?>
|
||||
&& equals(type, ((TypeKey<?>) o).type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return ReflectionUtil.typeToString(type);
|
||||
}
|
||||
|
||||
public static boolean equals(Type a, Type b) {
|
||||
if(a == b) {
|
||||
return true;
|
||||
@@ -116,5 +88,39 @@ public class TypeKey<T> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw (non-generic) type for this type.
|
||||
*/
|
||||
public final Class<? super T> getRawType() {
|
||||
return rawType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets underlying {@code Type} instance.
|
||||
*/
|
||||
public final Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public AnnotatedType getAnnotatedType() {
|
||||
return annotatedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return this.hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
return o instanceof TypeKey<?>
|
||||
&& equals(type, ((TypeKey<?>) o).type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return ReflectionUtil.typeToString(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user