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

io.deephaven.appmode.StandardField Maven / Gradle / Ivy

There is a newer version: 0.36.1
Show newest version
//
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending
//
package io.deephaven.appmode;

import io.deephaven.annotations.BuildableStyle;
import org.immutables.value.Value.Check;
import org.immutables.value.Value.Immutable;

import java.util.Optional;

@Immutable
@BuildableStyle
public abstract class StandardField implements Field {

    public static  Field of(String name, T value) {
        return ImmutableStandardField.builder().name(name).value(value).build();
    }

    public static  Field of(String name, T value, String description) {
        return ImmutableStandardField.builder().name(name).value(value).description(description)
                .build();
    }

    public abstract String name();

    public abstract T value();

    public abstract Optional description();

    @Check
    final void checkName() {
        if (!ApplicationUtil.isAsciiPrintable(name())) {
            throw new IllegalArgumentException("name() is invalid, must be printable ascii");
        }
    }

    @Check
    final void checkDescription() {
        if (description().isPresent() && description().get().isEmpty()) {
            throw new IllegalArgumentException("description(), when present, must not be empty");
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy