selva.oss.ds.document.StoreGetApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lib Show documentation
Show all versions of lib Show documentation
Collection of libraries that make backend DX an oasis.
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();
}
}
}