mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-13 19:26:14 +00:00
Change Java whitespace handling in .editorconfig (#425)
* Change whitespace handling in .editorconfig * Reformat code * fix format error * Reformat code --------- Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
@@ -22,111 +22,111 @@ public class MetaTest {
|
||||
public void testMetaList() {
|
||||
Configuration meta = new YamlConfiguration(MetaTest.class.getResourceAsStream("/meta.yml"), "meta.yml");
|
||||
Configuration metaTarget = new YamlConfiguration(MetaTest.class.getResourceAsStream("/metaTarget.yml"), "metaTarget.yml");
|
||||
|
||||
|
||||
Map<String, Configuration> configurationMap = new HashMap<>();
|
||||
|
||||
|
||||
configurationMap.put(meta.getName(), meta);
|
||||
configurationMap.put(metaTarget.getName(), metaTarget);
|
||||
|
||||
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
loader.registerPreprocessor(Meta.class, new MetaStringPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaListLikePreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaNumberPreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.load(new MetaListConfig(), meta).list.forEach(System.out::println);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMetaMap() {
|
||||
Configuration meta = new YamlConfiguration(MetaTest.class.getResourceAsStream("/meta.yml"), "meta.yml");
|
||||
Configuration metaTarget = new YamlConfiguration(MetaTest.class.getResourceAsStream("/metaTarget.yml"), "metaTarget.yml");
|
||||
|
||||
|
||||
Map<String, Configuration> configurationMap = new HashMap<>();
|
||||
|
||||
|
||||
configurationMap.put(meta.getName(), meta);
|
||||
configurationMap.put(metaTarget.getName(), metaTarget);
|
||||
|
||||
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
loader.registerPreprocessor(Meta.class, new MetaStringPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaListLikePreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaNumberPreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.load(new MetaMapConfig(), meta).map.forEach((k, v) -> System.out.println(k + ": " + v));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMetaString() {
|
||||
Configuration meta = new YamlConfiguration(MetaTest.class.getResourceAsStream("/meta.yml"), "meta.yml");
|
||||
Configuration metaTarget = new YamlConfiguration(MetaTest.class.getResourceAsStream("/metaTarget.yml"), "metaTarget.yml");
|
||||
|
||||
|
||||
Map<String, Configuration> configurationMap = new HashMap<>();
|
||||
|
||||
|
||||
configurationMap.put(meta.getName(), meta);
|
||||
configurationMap.put(metaTarget.getName(), metaTarget);
|
||||
|
||||
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
|
||||
|
||||
loader.registerPreprocessor(Meta.class, new MetaStringPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaListLikePreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaNumberPreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||
|
||||
|
||||
System.out.println(loader.load(new MetaStringConfig(), meta).string);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMetaNumber() {
|
||||
Configuration meta = new YamlConfiguration(MetaTest.class.getResourceAsStream("/meta.yml"), "meta.yml");
|
||||
Configuration metaTarget = new YamlConfiguration(MetaTest.class.getResourceAsStream("/metaTarget.yml"), "metaTarget.yml");
|
||||
|
||||
|
||||
Map<String, Configuration> configurationMap = new HashMap<>();
|
||||
|
||||
|
||||
configurationMap.put(meta.getName(), meta);
|
||||
configurationMap.put(metaTarget.getName(), metaTarget);
|
||||
|
||||
|
||||
ConfigLoader loader = new ConfigLoader();
|
||||
loader.registerPreprocessor(Meta.class, new MetaStringPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaListLikePreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaMapPreprocessor(configurationMap));
|
||||
loader.registerPreprocessor(Meta.class, new MetaNumberPreprocessor(configurationMap));
|
||||
|
||||
|
||||
loader.registerPreprocessor(Meta.class, new MetaValuePreprocessor(configurationMap));
|
||||
|
||||
|
||||
System.out.println("int: " + loader.load(new MetaNumberConfig(), meta).integer);
|
||||
System.out.println("double: " + loader.load(new MetaNumberConfig(), meta).aDouble);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static final class MetaListConfig implements ConfigTemplate {
|
||||
@Value("list")
|
||||
private @Meta List<@Meta String> list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static final class MetaMapConfig implements ConfigTemplate {
|
||||
@Value("map")
|
||||
private @Meta Map<@Meta String, @Meta String> map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static final class MetaStringConfig implements ConfigTemplate {
|
||||
@Value("string")
|
||||
private @Meta String string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static final class MetaNumberConfig implements ConfigTemplate {
|
||||
@Value("int")
|
||||
private @Meta int integer;
|
||||
|
||||
|
||||
@Value("double")
|
||||
private @Meta double aDouble;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.dfsek.terra.profiler.ProfilerImpl;
|
||||
|
||||
public class ProfilerTest {
|
||||
private static final Profiler PROFILER = new ProfilerImpl();
|
||||
|
||||
|
||||
private static void doThing() throws InterruptedException {
|
||||
PROFILER.push("thing");
|
||||
Thread.sleep(1);
|
||||
@@ -33,7 +33,7 @@ public class ProfilerTest {
|
||||
thing4();
|
||||
PROFILER.pop("thing");
|
||||
}
|
||||
|
||||
|
||||
private static void doOtherThing() throws InterruptedException {
|
||||
PROFILER.push("thing2");
|
||||
Thread.sleep(2);
|
||||
@@ -41,30 +41,30 @@ public class ProfilerTest {
|
||||
thing4();
|
||||
PROFILER.pop("thing2");
|
||||
}
|
||||
|
||||
|
||||
private static void doThirdOtherThing() throws InterruptedException {
|
||||
PROFILER.push("thing3");
|
||||
Thread.sleep(2);
|
||||
PROFILER.pop("thing3");
|
||||
}
|
||||
|
||||
|
||||
private static void thing4() throws InterruptedException {
|
||||
PROFILER.push("thing4");
|
||||
Thread.sleep(2);
|
||||
PROFILER.pop("thing4");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testProfiler() throws InterruptedException {
|
||||
//PROFILER.start();
|
||||
for(int i = 0; i < 100; i++) {
|
||||
doThing();
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < 100; i++) {
|
||||
doThirdOtherThing();
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < 100; i++) {
|
||||
doOtherThing();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class ProfilerTest {
|
||||
PROFILER.pop("thing");
|
||||
PROFILER.push("thing4");
|
||||
PROFILER.pop("thing4");
|
||||
|
||||
|
||||
PROFILER.getTimings().forEach((id, timings) -> System.out.println(id + ": " + timings.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,63 +34,63 @@ public class RegistryTest {
|
||||
@Test
|
||||
public void openRegistry() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
|
||||
|
||||
assertEquals(test.get(RegistryKey.parse("test:test")).orElseThrow(), "bazinga");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void openRegistryChecked() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga");
|
||||
|
||||
|
||||
try {
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga2");
|
||||
fail("Shouldn't be able to re-register with #registerChecked!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void checkedRegistry() {
|
||||
CheckedRegistry<String> test = new CheckedRegistryImpl<>(new OpenRegistryImpl<>(TypeKey.of(String.class)));
|
||||
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
|
||||
|
||||
assertEquals(test.get(RegistryKey.parse("test:test")).orElseThrow(), "bazinga");
|
||||
|
||||
|
||||
try {
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga2");
|
||||
fail("Shouldn't be able to re-register in CheckedRegistry!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getID() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
|
||||
|
||||
assertEquals(test.getByID("test").orElseThrow(), "bazinga");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getIDAmbiguous() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga");
|
||||
test.registerChecked(RegistryKey.parse("test2:test"), "bazinga");
|
||||
|
||||
|
||||
try {
|
||||
test.getByID("test");
|
||||
fail("Shouldn't be able to get with ambiguous ID!");
|
||||
} catch(IllegalArgumentException ignore) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user