com.zuunr.json.schema.validation.node.number.MultipleOfNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json Show documentation
Show all versions of json Show documentation
Immutable JSON representation in Java
package com.zuunr.json.schema.validation.node.number;
import com.zuunr.json.JsonNumber;
import com.zuunr.json.JsonValue;
import com.zuunr.json.schema.Keywords;
import com.zuunr.json.schema.JsonSchema;
import com.zuunr.json.schema.validation.ValidationContext;
import com.zuunr.json.schema.validation.node.KeywordNode;
/**
* @author Niklas Eldberger
*/
public class MultipleOfNode extends KeywordNode {
public MultipleOfNode(JsonValue instance, JsonSchema schema, int keywordIndex, ValidationContext validationContext, JsonValue rootInstance) {
super(instance, schema, keywordIndex, validationContext, rootInstance);
}
@Override
protected Boolean calculateValid() {
JsonNumber multipleOf = schema.getKeyword(Keywords.MULTIPLE_OF, JsonValue.NULL).getJsonNumber();
long modulo = instance.getJsonNumber().longValue() % multipleOf.longValue();
return instance.getJsonNumber().isJsonInteger() && modulo == 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy