selva.oss.ds.document.DocumentExistanceAndEqualityApi 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 DocumentExistanceAndEqualityApi {
default boolean isPresent(T field) {
throw new HasNotBeenImplementedException();
}
default boolean isEqual(DocumentStore inData, T field) {
throw new HasNotBeenImplementedException();
}
default boolean diffAndCheckIfEdited(DocumentStore inData, T field) {
throw new HasNotBeenImplementedException();
}
}
interface DocumentExistanceAndEqualityOps extends DocumentBaseApi, DocumentStore {
default boolean isPresent(String field) {
return containsValue(DocumentParamsStateValidator.createWithValidField(field));
}
default boolean isEqual(DocumentStore inData, String field) {
validateNotNull(inData);
validateNotNull(field);
if (!isPresent(field) || !inData.isPresent(field)) {
return false;
}
return getTypedValue(field).equals(inData.getTypedValue(field));
}
default boolean diffAndCheckIfEdited(DocumentStore inData, String field) {
validateNotNull(inData);
validateNotNull(field);
return ((!isPresent(field) && inData.isPresent(field)) || (isPresent(field) && inData.isPresent(field) && !getTypedValue(field).equals(inData.getTypedValue(field))));
}
}