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

de.bytefish.fcmjava.requests.topic.TopicUnicastMessage Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version
// Copyright (c) Philipp Wagner. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

package de.bytefish.fcmjava.requests.topic;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.bytefish.fcmjava.model.options.FcmMessageOptions;
import de.bytefish.fcmjava.model.topics.Topic;
import de.bytefish.fcmjava.requests.FcmUnicastMessage;
import de.bytefish.fcmjava.requests.notification.NotificationPayload;

public class TopicUnicastMessage extends FcmUnicastMessage {

    private final Object data;
    private final NotificationPayload notification;

    public TopicUnicastMessage(FcmMessageOptions options, Topic to, Object data) {
        this(options, to, data, null);
    }

    public TopicUnicastMessage(FcmMessageOptions options, Topic to, NotificationPayload notification) {
        this(options, to, null, notification);
    }

    public TopicUnicastMessage(FcmMessageOptions options, Topic to, Object data, NotificationPayload notification) {
        super(options, to.getTopicPath());

        this.data = data;
        this.notification = notification;
    }

    @Override
    @JsonProperty("data")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object getPayload() {
        return data;
    }

    @JsonProperty("notification")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public NotificationPayload getNotificationPayload() {
        return this.notification;
    }
}