aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl3/impl/SafeBinding.java
blob: c55d2be04789828e01b8dd0bc12d508390bbcc0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package dev.isxander.yacl3.impl;

import dev.isxander.yacl3.api.Binding;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public class SafeBinding<T> implements Binding<T> {
    private final Binding<T> binding;

    public SafeBinding(Binding<T> binding) {
        this.binding = binding;
    }

    @Override
    public @NotNull T getValue() {
        return Objects.requireNonNull(binding.getValue());
    }

    @Override
    public void setValue(@NotNull T value) {
        binding.setValue(Objects.requireNonNull(value));
    }

    @Override
    public @NotNull T defaultValue() {
        return Objects.requireNonNull(binding.defaultValue());
    }
}