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

au.org.consumerdatastandards.support.model.EndpointModel Maven / Gradle / Ivy

Go to download

This artefact describes the Consumer Data Standards using Java classes and annotations in a way suitable for automatic generation of Open API Specification, documentation, Server Stub, Client Libraries and Reference Test.

There is a newer version: 1.1.1
Show newest version
package au.org.consumerdatastandards.support.model;

import au.org.consumerdatastandards.support.Endpoint;
import au.org.consumerdatastandards.support.ParamLocation;

import java.util.*;

public class EndpointModel extends ModelBase implements Comparable {

    private Endpoint endpoint;

    private Set paramModels = new TreeSet<>();

    private Map> paramsByLocation = new HashMap<>();

    public EndpointModel(Endpoint endpoint) {
        this.endpoint = endpoint;
    }

    public Endpoint getEndpoint() {
        return endpoint;
    }

    public Set getParamModels() {
        return paramModels;
    }


    public void addParamModel(ParamModel paramModel) {

        paramModels.add(paramModel);
        paramsByLocation.computeIfAbsent(paramModel.getParam().in(), k -> new LinkedHashSet<>());
        paramsByLocation.get(paramModel.getParam().in()).add(paramModel);
    }

    @Override
    public int compareTo(EndpointModel endpointModel) {

        int result = endpoint.path().replaceAll("[\\{|\\}]", "").compareTo(endpointModel.endpoint.path().replaceAll("[\\{|\\}]", ""));
        if (result != 0) return result;
        return endpoint.requestMethod().name().compareTo(endpointModel.endpoint.requestMethod().name());
    }

    public Set getHeadParams() {

        return paramsByLocation.get(ParamLocation.HEADER);
    }

    public Set getBodyParams() {

        return paramsByLocation.get(ParamLocation.BODY);
    }

    public Set getFormParams() {

        return paramsByLocation.get(ParamLocation.FORM);
    }

    public Set getQueryParams() {

        return paramsByLocation.get(ParamLocation.QUERY);
    }

    public Set getPathParams() {

        return paramsByLocation.get(ParamLocation.PATH);
    }

    public Set getCookieParams() {

        return paramsByLocation.get(ParamLocation.COOKIE);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy