Skip to content

Commit

Permalink
リファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
Maru32768 committed Jan 4, 2023
1 parent f04d6d4 commit b85c3f6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public CollectionValue(T value) {
super(value);
}

protected boolean addableByCommand() {
protected final boolean addableByCommand() {
return addable;
}

public U addableByCommand(boolean addable) {
public final U addableByCommand(boolean addable) {
this.addable = addable;
return ((U) this);
}
Expand Down Expand Up @@ -58,11 +58,11 @@ protected String succeedMessageForAdd(String entryName, T value) {
return String.format("%sに%sを追加しました.", entryName, elementToString(((E[]) value.toArray())[0]));
}

protected boolean removableByCommand() {
protected final boolean removableByCommand() {
return removable;
}

public U removableByCommand(boolean removable) {
public final U removableByCommand(boolean removable) {
this.removable = removable;
return ((U) this);
}
Expand Down Expand Up @@ -94,11 +94,11 @@ protected String succeedMessageForRemove(String entryName, T value) {
return String.format("%sから%sを削除しました.", entryName, elementToString(((E[]) value.toArray())[0]));
}

protected boolean clearableByCommand() {
protected final boolean clearableByCommand() {
return clearable;
}

public U clearableByCommand(boolean clearable) {
public final U clearableByCommand(boolean clearable) {
this.clearable = clearable;
return ((U) this);
}
Expand Down
12 changes: 6 additions & 6 deletions common/src/main/java/net/kunmc/lab/configlib/MapValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public MapValue(Map<K, V> value) {
super(value);
}

protected boolean puttableByCommand() {
protected final boolean puttableByCommand() {
return puttable;
}

public T puttableByCommand(boolean puttable) {
public final T puttableByCommand(boolean puttable) {
this.puttable = puttable;
return ((T) this);
}
Expand Down Expand Up @@ -83,11 +83,11 @@ protected String succeedMessageForPut(String entryName, K k, V v) {
return String.format("%sに{%s:%s}を追加しました.", entryName, keyToString(k), valueToString(v));
}

protected boolean removableByCommand() {
protected final boolean removableByCommand() {
return removable;
}

public T removableByCommand(boolean removable) {
public final T removableByCommand(boolean removable) {
this.removable = removable;
return ((T) this);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ protected String succeedMessageForRemove(String entryName, K k, V v) {
return String.format("%sから{%s:%s}を削除しました.", entryName, keyToString(k), valueToString(v));
}

protected boolean clearableByCommand() {
protected final boolean clearableByCommand() {
return clearable;
}

Expand All @@ -139,7 +139,7 @@ public final T onClear(Runnable listener) {
return ((T) this);
}

protected void onClearMap() {
protected final void onClearMap() {
clearListeners.forEach(Runnable::run);
}

Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/net/kunmc/lab/configlib/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ public void value(E value) {
this.value = value;
}

public String description() {
public final String description() {
return description;
}

public T description(String description) {
public final T description(String description) {
this.description = description;
return ((T) this);
}

protected boolean listable() {
protected final boolean listable() {
return listable;
}

public T listable(boolean listable) {
public final T listable(boolean listable) {
this.listable = listable;
return ((T) this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,10 @@
import java.util.stream.Stream;

public abstract class ListValue<E, U extends ListValue<E, U>> extends CollectionValue<List<E>, E, U> implements Iterable<E> {
protected transient boolean listable = true;
protected transient boolean addable = true;
protected transient boolean removable = true;
protected transient boolean clearable = true;

public ListValue(List<E> value) {
super(value);
}

@Override
public boolean addableByCommand() {
return addable;
}

public U addableByCommand(boolean addable) {
this.addable = addable;
return (U) this;
}

@Override
protected boolean validateForAdd(String entryName, List<E> value, CommandContext ctx) {
return true;
Expand All @@ -38,16 +23,6 @@ protected String invalidValueMessageForAdd(String entryName, List<E> value, Comm
return "This message can't be shown.";
}

@Override
public boolean removableByCommand() {
return removable;
}

public U removableByCommand(boolean removable) {
this.removable = removable;
return (U) this;
}

@Override
public boolean validateForRemove(String entryName, List<E> element, CommandContext ctx) {
return value.containsAll(element);
Expand All @@ -62,26 +37,6 @@ protected final String invalidValueMessageForRemove(String entryName, List<E> va
entryName);
}

@Override
public boolean clearableByCommand() {
return clearable;
}

public U clearableByCommand(boolean clearable) {
this.clearable = clearable;
return (U) this;
}

@Override
public boolean listable() {
return listable;
}

public U listable(boolean listable) {
this.listable = listable;
return (U) this;
}

public int size() {
return value.size();
}
Expand Down

0 comments on commit b85c3f6

Please sign in to comment.