mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-06 00:08:04 +01:00
refactor: Change name to optional and fix inheritDoc typo
This commit is contained in:
parent
cb5877b206
commit
c8ae27894e
@ -1,5 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.utils.settings.node;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -25,7 +27,7 @@ public class MVValueNode<T> extends MVCommentedNode implements NamedValueNode<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@InheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public @NotNull Class<T> getType() {
|
||||
@ -33,7 +35,7 @@ public class MVValueNode<T> extends MVCommentedNode implements NamedValueNode<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@InheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public @Nullable T getDefaultValue() {
|
||||
@ -41,11 +43,11 @@ public class MVValueNode<T> extends MVCommentedNode implements NamedValueNode<T>
|
||||
}
|
||||
|
||||
/**
|
||||
* {@InheritDoc}
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public @Nullable String getName() {
|
||||
return name;
|
||||
public Optional<String> getName() {
|
||||
return Optional.ofNullable(name);
|
||||
}
|
||||
|
||||
public static class Builder<T, B extends Builder<T, B>> extends MVCommentedNode.Builder<B> {
|
||||
@ -54,18 +56,18 @@ public class MVValueNode<T> extends MVCommentedNode implements NamedValueNode<T>
|
||||
protected T defaultValue;
|
||||
private String name;
|
||||
|
||||
public Builder(String path, Class<T> type) {
|
||||
public Builder(@NotNull String path, @NotNull Class<T> type) {
|
||||
super(path);
|
||||
this.type = type;
|
||||
this.name = path;
|
||||
}
|
||||
|
||||
public B defaultValue(T defaultValue) {
|
||||
public B defaultValue(@NotNull T defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return (B) this;
|
||||
}
|
||||
|
||||
public B name(String name) {
|
||||
public B name(@Nullable String name) {
|
||||
this.name = name;
|
||||
return (B) this;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.utils.settings.node;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import io.github.townyadvanced.commentedconfiguration.setting.TypedValueNode;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -9,5 +11,5 @@ public interface NamedValueNode<T> extends TypedValueNode<T> {
|
||||
*
|
||||
* @return The name of this node.
|
||||
*/
|
||||
@Nullable String getName();
|
||||
Optional<String> getName();
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ public class NodeGroup implements Collection<CommentedNode> {
|
||||
}
|
||||
|
||||
private void addNodeIndex(CommentedNode node) {
|
||||
if (node instanceof NamedValueNode namedValueNode && namedValueNode.getName() != null) {
|
||||
nodesMap.put(namedValueNode.getName(), node);
|
||||
if (node instanceof NamedValueNode) {
|
||||
((NamedValueNode<?>) node).getName().ifPresent(name -> nodesMap.put(name, node));
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNodeIndex(CommentedNode node) {
|
||||
if (node instanceof NamedValueNode namedValueNode) {
|
||||
nodesMap.remove(namedValueNode.getName());
|
||||
if (node instanceof NamedValueNode) {
|
||||
((NamedValueNode<?>) node).getName().ifPresent(nodesMap::remove);
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class NodeGroup implements Collection<CommentedNode> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T @NotNull [] toArray(@NotNull T[] ts) {
|
||||
public <T> T @NotNull [] toArray(T @NotNull [] ts) {
|
||||
return nodes.toArray(ts);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user