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

net.optionfactory.whatsapp.dto.messages.Component Maven / Gradle / Ivy

package net.optionfactory.whatsapp.dto.messages;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import net.optionfactory.whatsapp.dto.messages.type.ComponentType;

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

/**
 * The type Component.
 */

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = As.EXISTING_PROPERTY, property = "type")
@JsonSubTypes({@JsonSubTypes.Type(value = ButtonComponent.class, name = "button"), //
        @JsonSubTypes.Type(value = HeaderComponent.class, name = "header"), //
        @JsonSubTypes.Type(value = BodyComponent.class, name = "body")})//
public abstract class Component> {
    @JsonProperty("type")
    private final ComponentType type;
    @JsonProperty("parameters")
    private List parameters;


    /**
     * Instantiates a new Component.
     *
     * @param type the type
     */
    @JsonCreator
    protected Component(ComponentType type) {
        this.type = type;
    }

    /**
     * Gets type.
     *
     * @return the type
     */
    public ComponentType getType() {
        return type;
    }


    /**
     * Gets parameters.
     *
     * @return the parameters
     */
    public List getParameters() {
        return parameters;
    }

    /**
     * Sets parameters.
     *
     * @param parameters the parameters
     * @return the parameters
     */
    public Component setParameters(List parameters) {
        this.parameters = parameters;
        return this;
    }

    /**
     * Add parameter component.
     *
     * @param parameter the parameter
     * @return the component
     */
    public Component addParameter(Parameter parameter) {
        if (this.parameters == null) this.parameters = new ArrayList<>();

        this.parameters.add(parameter);

        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy