com.hltech.vaunt.validator.schema.IntegerSchemaValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsSchemaType() 0 3 1
A validate(JsonSchema,JsonSchema) 0 16 2
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