package org.bubblecloud.zigbee.v3.zcl.protocol.command.ias.ace;

import org.bubblecloud.zigbee.v3.zcl.ZclCommandMessage;
import org.bubblecloud.zigbee.v3.zcl.ZclCommand;
import org.bubblecloud.zigbee.v3.zcl.protocol.ZclCommandType;
import org.bubblecloud.zigbee.v3.zcl.protocol.ZclFieldType;
import org.bubblecloud.zigbee.v3.zcl.field.*;

import java.util.List;

/**
 * Code generated Bypass Command value object class.
 */
public class BypassCommand extends ZclCommand {
    /**
     * Number of Zones command message field.
     */
    private Integer numberOfZones;
    /**
     * Zone IDs command message field.
     */
    private List<Unsigned8BitInteger> zoneIDs;

    /**
     * Default constructor setting the command type field.
     */
    public BypassCommand() {
        this.setType(ZclCommandType.BYPASS_COMMAND);
    }

    /**
     * Constructor copying field values from command message.
     * @param message the command message
     */
    public BypassCommand(final ZclCommandMessage message) {
        super(message);
        this.numberOfZones = (Integer) message.getFields().get(ZclFieldType.BYPASS_COMMAND_NUMBER_OF_ZONES);
        this.zoneIDs = (List<Unsigned8BitInteger>) message.getFields().get(ZclFieldType.BYPASS_COMMAND_ZONE_IDS);
    }

    @Override
    public ZclCommandMessage toCommandMessage() {
        final ZclCommandMessage message = super.toCommandMessage();
        message.getFields().put(ZclFieldType.BYPASS_COMMAND_NUMBER_OF_ZONES,numberOfZones);
        message.getFields().put(ZclFieldType.BYPASS_COMMAND_ZONE_IDS,zoneIDs);
        return message;
    }

    /**
     * Gets Number of Zones.
     * @return the Number of Zones
     */
    public Integer getNumberOfZones() {
        return numberOfZones;
    }

    /**
     * Sets Number of Zones.
     * @param numberOfZones the Number of Zones
     */
    public void setNumberOfZones(final Integer numberOfZones) {
        this.numberOfZones = numberOfZones;
    }

    /**
     * Gets Zone IDs.
     * @return the Zone IDs
     */
    public List<Unsigned8BitInteger> getZoneIDs() {
        return zoneIDs;
    }

    /**
     * Sets Zone IDs.
     * @param zoneIDs the Zone IDs
     */
    public void setZoneIDs(final List<Unsigned8BitInteger> zoneIDs) {
        this.zoneIDs = zoneIDs;
    }

    @Override
    public String toString() {
        final StringBuilder builder = new StringBuilder();
        builder.append(super.toString());
        builder.append(", ");
        builder.append("numberOfZones");
        builder.append('=');
        builder.append(numberOfZones);
        builder.append(", ");
        builder.append("zoneIDs");
        builder.append('=');
        builder.append(zoneIDs);
        return builder.toString();
    }

}
