All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.osvaldopina.signedcontract.enforcer.jsonhal.HalLinkCountClauseEnforcer Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package com.github.osvaldopina.signedcontract.enforcer.jsonhal;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.osvaldopina.signedcontract.enforcer.EnforcementError;
import com.github.osvaldopina.signedcontract.enforcer.LeafClauseEnforcer;

import java.util.ArrayList;
import java.util.List;

public class HalLinkCountClauseEnforcer extends LeafClauseEnforcer implements HalLinksClauseEnforcer{

    private int linkCount;

    public HalLinkCountClauseEnforcer(int linkCount) {
        super();
        this.linkCount = linkCount;
    }


    @Override
    protected List enforceClause(JsonNode documentClause) {

        List errors = new ArrayList();

        if (documentClause.size() != linkCount) {
            errors.add(new EnforcementError("Was expecting to have " + linkCount + " link(s) but _links has " +
                    documentClause.size() + " link(s)."));
        }

        return errors;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy