Skip to content

Commit

Permalink
Rename SettingArgument factory methods to be less verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltak committed Aug 13, 2019
1 parent 056d8c8 commit 6d2ec48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Expand Up @@ -22,13 +22,13 @@

public class TestAutoConfig extends AutoConfig {
public final Setting<String> stringSetting = setting(
valueType(String.class),
type(String.class),
defaultValue(""),
humanReadableName("Human Readable Name")
name("Human Readable Name")
);

public final Setting<ImmutableList<Integer>> integerListSetting = setting(
valueType(new TypeInfo<ImmutableList<Integer>>() {}),
type(new TypeInfo<ImmutableList<Integer>>() {}),
defaultValue(ImmutableList.of())
);
}
Expand Up @@ -25,7 +25,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.*;
import static org.terasology.config.flexible.SettingArgument.*;

Expand Down Expand Up @@ -53,10 +52,10 @@ public void testSettingDsl() {
String description = "description";

Setting<Double> setting = AutoConfig.setting(
valueType(Double.class),
type(Double.class),
defaultValue(defaultValue),
constraint(constraint),
humanReadableName(name),
name(name),
description(description)
);

Expand Down
Expand Up @@ -35,19 +35,19 @@ public static <V> SettingArgument<V, V> defaultValue(V defaultValue) {
return new SettingArgument<>(defaultValue, SettingBuilder::defaultValue);
}

public static <V> SettingArgument<TypeInfo<V>, V> valueType(Class<V> valueClass) {
return valueType(TypeInfo.of(valueClass));
public static <V> SettingArgument<TypeInfo<V>, V> type(Class<V> valueClass) {
return type(TypeInfo.of(valueClass));
}

public static <V> SettingArgument<TypeInfo<V>, V> valueType(TypeInfo<V> valueType) {
public static <V> SettingArgument<TypeInfo<V>, V> type(TypeInfo<V> valueType) {
return new SettingArgument<>(valueType, SettingBuilder::valueType);
}

public static <V> SettingArgument<SettingConstraint<V>, V> constraint(SettingConstraint<V> constraint) {
return new SettingArgument<>(constraint, SettingBuilder::constraint);
}

public static <V> SettingArgument<String, V> humanReadableName(String humanReadableName) {
public static <V> SettingArgument<String, V> name(String humanReadableName) {
return new SettingArgument<>(humanReadableName, SettingBuilder::humanReadableName);
}

Expand Down

0 comments on commit 6d2ec48

Please sign in to comment.