@@ -12,15 +12,15 @@ public class PushPayload implements PushModel {
1212 private final Audience audience ;
1313 private final Notification notification ;
1414 private final Message message ;
15- private Optional optional ;
15+ private Options options ;
1616
1717 private PushPayload (Platform platform , Audience audience ,
18- Notification notification , Message message , Optional optional ) {
18+ Notification notification , Message message , Options options ) {
1919 this .platform = platform ;
2020 this .audience = audience ;
2121 this .notification = notification ;
2222 this .message = message ;
23- this .optional = optional ;
23+ this .options = options ;
2424 }
2525
2626 public static Builder newBuilder () {
@@ -39,19 +39,19 @@ public static PushPayload simpleMessageAll(String content) {
3939 .setMessage (Message .content (content )).build ();
4040 }
4141
42- public void resetOptionalApnsProduction (boolean apnsProduction ) {
43- if (null == optional ) {
44- optional = Optional .newBuilder ().setApnsProduction (apnsProduction ).build ();
42+ public void resetOptionsApnsProduction (boolean apnsProduction ) {
43+ if (null == options ) {
44+ options = Options .newBuilder ().setApnsProduction (apnsProduction ).build ();
4545 } else {
46- optional .setApnsProduction (apnsProduction );
46+ options .setApnsProduction (apnsProduction );
4747 }
4848 }
4949
50- public void resetOptionalTimeToLive (long timeToLive ) {
51- if (null == optional ) {
52- optional = Optional .newBuilder ().setTimeToLive (timeToLive ).build ();
50+ public void resetOptionsTimeToLive (long timeToLive ) {
51+ if (null == options ) {
52+ options = Options .newBuilder ().setTimeToLive (timeToLive ).build ();
5353 } else {
54- optional .setTimeToLive (timeToLive );
54+ options .setTimeToLive (timeToLive );
5555 }
5656 }
5757
@@ -67,17 +67,17 @@ public JsonElement toJSON() {
6767 json .add (Message .MESSAGE , message .toJSON ());
6868 }
6969 if (null != message ) {
70- json .add (Optional .OPTIONAL , optional .toJSON ());
70+ json .add (Options .OPTIONAL , options .toJSON ());
7171 }
7272 return json ;
7373 }
7474
7575 public static class Builder {
76- private Platform platform = Platform . all () ;
76+ private Platform platform = null ;
7777 private Audience audience = null ;
7878 private Notification notification = null ;
7979 private Message message = null ;
80- private Optional optional = null ;
80+ private Options options = null ;
8181
8282 public Builder setPlatform (Platform platform ) {
8383 this .platform = platform ;
@@ -99,15 +99,15 @@ public Builder setMessage(Message message) {
9999 return this ;
100100 }
101101
102- public Builder setOptional ( Optional optional ) {
103- this .optional = optional ;
102+ public Builder setOptions ( Options options ) {
103+ this .options = options ;
104104 return this ;
105105 }
106106
107107 public PushPayload build () {
108- Preconditions .checkArgument (null != audience , "Audience should be set." );
108+ Preconditions .checkArgument (! ( null == audience || null == platform ) , "Audience should be set." );
109109 Preconditions .checkArgument (! (null == notification && null == message ), "notification or message should be set at least one." );
110- return new PushPayload (platform , audience , notification , message , optional );
110+ return new PushPayload (platform , audience , notification , message , options );
111111 }
112112 }
113113}
0 commit comments