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

selva.oss.ds.document.StoreGetApi Maven / Gradle / Ivy

The newest version!
package selva.oss.ds.document;

import static selva.oss.lang.Commons.*;
import selva.oss.ds.document.datatype.DataTypeConfig;
import selva.oss.ds.document.datatype.TypedValue;

import java.util.*;

interface StoreGetApi {

    public TypedValue getTypedValue(T field);

    public Optional getTypedValueOptional(String field);

    public DataTypeConfig getConfig(String field);

    public boolean isFieldPresent(String field);

    public void verifyFieldExist(String field);

}

interface StoreGetOps extends DocumentBaseApi, DocumentStore {

    default TypedValue getTypedValue(String field) {
        return fetchTypedValueSure(DocumentParamsStateValidator.createWithValidField(field));
    }

    default Optional getTypedValueOptional(String field) {
        return fetchTypedValue(DocumentParamsStateValidator.createWithValidField(field));
    }

    default DataTypeConfig getConfig(String field) {
        return fetchConfigSure(DocumentParamsStateValidator.createWithValidField(field));
    }

    default boolean isFieldPresent(String field) {
        return containsField(DocumentParamsStateValidator.createWithField(field));
    }

    public static class FieldDoesNotExistException extends RuntimeException {
    }

    default void verifyFieldExist(String field) {
        if (!isFieldPresent(field)) {
            throw new FieldDoesNotExistException();
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy