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

com.global.api.terminals.hpa.builders.HpaAdminBuilder Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
package com.global.api.terminals.hpa.builders;

import com.global.api.entities.exceptions.BuilderException;
import com.global.api.utils.StringUtils;

public class HpaAdminBuilder {
    private StringBuilder messageBuilder;
    private String[] messageIds;

    private boolean keepAlive;
    private boolean awaitResponse;

    public String[] getMessageIds() {
        return messageIds;
    }

    public boolean isKeepAlive() {
        return keepAlive;
    }

    public void setKeepAlive(boolean keepAlive) {
        this.keepAlive = keepAlive;
    }

    public boolean isAwaitResponse() {
        return awaitResponse;
    }

    public void setAwaitResponse(boolean awaitResponse) {
        this.awaitResponse = awaitResponse;
    }

    public HpaAdminBuilder(String... messageIds) throws BuilderException {
        if(messageIds.length <= 0) {
            throw new BuilderException("You must provide at least one message id.");
        }

        messageBuilder = new StringBuilder();
        messageBuilder.append(String.format("1.01004%s", messageIds[0]));
        this.messageIds = messageIds;
        this.keepAlive = false;
        this.awaitResponse = true;
    }

    public HpaAdminBuilder set(String tagName, Integer value) {
        if(value != null) {
            messageBuilder.append(String.format("<%s>%s", tagName, value, tagName));
        }
        return this;
    }
    public HpaAdminBuilder set(String tagName, String value) {
        if(!StringUtils.isNullOrEmpty(value)) {
            messageBuilder.append(String.format("<%s>%s", tagName, value, tagName));
        }
        return this;
    }

    public String buildMessage() {
        messageBuilder.append("");
        return messageBuilder.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy