validate(JsonSchema,JsonSchema)   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
c 0
b 0
f 0
dl 0
loc 16
rs 9.8
1
package com.hltech.vaunt.validator.schema;
2
3
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
4
import com.fasterxml.jackson.module.jsonSchema.types.IntegerSchema;
5
6
import java.util.List;
7
8
public class IntegerSchemaValidator extends NumberSchemaValidator {
9
10
    @Override
11
    public List<String> validate(JsonSchema consumerSchema, JsonSchema providerSchema) {
12
        List<String> errors = super.validate(consumerSchema, providerSchema);
13
14
        IntegerSchema consumerIntegerSchema = consumerSchema.asIntegerSchema();
15
        IntegerSchema providerIntegerSchema = providerSchema.asIntegerSchema();
16
17
        if (!isValid(consumerIntegerSchema.getDivisibleBy(), providerIntegerSchema.getDivisibleBy())) {
18
            errors.add(String.format(ERROR_FORMAT,
19
                    consumerIntegerSchema.getId(),
20
                    "divisibleBy",
21
                    consumerIntegerSchema.getDivisibleBy(),
22
                    providerIntegerSchema.getDivisibleBy()));
23
        }
24
25
        return errors;
26
    }
27
28
    @Override
29
    public Class<?> supportsSchemaType() {
30
        return IntegerSchema.class;
31
    }
32
}
33