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

com.urbanairship.api.push.model.notification.Interactive Maven / Gradle / Ivy

There is a newer version: 9.4.2
Show newest version
/*
 * Copyright (c) 2013-2016.  Urban Airship and Contributors
 */

package com.urbanairship.api.push.model.notification;

import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.urbanairship.api.push.model.notification.actions.Actions;

public class Interactive {
    private final String type;
    private final ImmutableMap buttonActions;

    private Interactive(String type, ImmutableMap buttonActions) {
        this.type = type;
        this.buttonActions = buttonActions;
    }

    public String getType() {
        return type;
    }

    public ImmutableMap getButtonActions() {
        return buttonActions;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Interactive that = (Interactive) o;

        return Objects.equal(type, that.type)
            && Objects.equal(buttonActions, that.buttonActions);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(type, buttonActions);
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(getClass())
            .add("type", type)
            .add("buttonActions", buttonActions)
            .toString();
    }

    public static class Builder {
        private String type = null;
        private ImmutableMap buttonActions = null;

        public Builder setType(String type) {
            this.type = type;
            return this;
        }

        public Builder setButtonActions(ImmutableMap buttonActions) {
            this.buttonActions = buttonActions;
            return this;
        }

        public Interactive build() {
            Preconditions.checkNotNull(type, "interactive payload requires a 'type' field");
            if (buttonActions == null) {
                buttonActions = ImmutableMap.of();
            }

            return new Interactive(type, buttonActions);
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy