io.github.yawenok.fcm.client.request.FcmTopicMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fcm-client Show documentation
Show all versions of fcm-client Show documentation
FCM client for java!Based on HttpAsyncClient.
The newest version!
package io.github.yawenok.fcm.client.request;
import com.alibaba.fastjson.annotation.JSONField;
import io.github.yawenok.fcm.client.options.FcmMessageOptions;
import java.util.List;
public class FcmTopicMessage extends FcmMessage {
private final String to;
private final String condition;
public FcmTopicMessage(final FcmMessageOptions options, final String topic, final Object data, final Object notification) {
super(options, data, notification);
if (topic == null) {
throw new IllegalArgumentException("topic");
}
this.to = "/topics/" + topic;
this.condition = null;
}
public FcmTopicMessage(final FcmMessageOptions options, final List topics, final Object data, final Object notification) {
super(options, data, notification);
if (topics == null) {
throw new IllegalArgumentException("topics");
}
StringBuffer topicsBuffer = new StringBuffer();
for (int i = 0;;) {
topicsBuffer.append("'" + topics.get(i) + "' in topics");
i++;
if (i < topics.size()) {
topicsBuffer.append(" || ");
} else {
break;
}
}
this.to = null;
this.condition = topicsBuffer.toString();
}
@JSONField(name = "to")
public String getTo() {
return to;
}
@JSONField(name = "condition")
public String getCondition() {
return condition;
}
}