All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.annotation.bytecode.BytecodeAnnotationStringValue Maven / Gradle / Ivy

There is a newer version: 1.26.147
Show newest version
package name.remal.annotation.bytecode;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.InvalidObjectException;
import java.io.ObjectInputValidation;

import static java.util.Objects.requireNonNull;

public class BytecodeAnnotationStringValue extends BytecodeAnnotationValue implements ObjectInputValidation {

    private static final long serialVersionUID = 1L;

    @NotNull
    private String value;

    @Contract("null->fail")
    public BytecodeAnnotationStringValue(@NotNull String value) {
        this.value = requireNonNull(value);
    }

    @NotNull
    public String getValue() {
        return value;
    }

    @Contract("null->fail")
    public void setValue(@NotNull String value) {
        this.value = requireNonNull(value);
    }

    @Override
    @NotNull
    public String toString() {
        return value;
    }

    @Override
    public boolean equals(@Nullable Object o) {
        if (this == o) return true;
        if (!(o instanceof BytecodeAnnotationStringValue)) return false;
        BytecodeAnnotationStringValue that = (BytecodeAnnotationStringValue) o;
        return value.equals(that.value);
    }

    @Override
    public int hashCode() {
        return value.hashCode();
    }

    @Override
    public boolean isString() {
        return true;
    }

    @Override
    @NotNull
    public BytecodeAnnotationStringValue asString() {
        return this;
    }

    // for deserialization
    @SuppressWarnings("ConstantConditions")
    @SuppressFBWarnings("NP_STORE_INTO_NONNULL_FIELD")
    private BytecodeAnnotationStringValue() {
        value = null;
    }

    @Override
    @SuppressWarnings("ConstantConditions")
    public void validateObject() throws InvalidObjectException {
        if (value == null) {
            throw new InvalidObjectException("value is null");
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy