Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / cacheinvalidation / src / java / com / google / ipc / invalidation / ticl / proto / AndroidListenerProtocol.java
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 // Generated by j/c/g/ipc/invalidation/common/proto_wrapper_generator
17 package com.google.ipc.invalidation.ticl.proto;
18
19 import com.google.ipc.invalidation.util.Bytes;
20 import com.google.ipc.invalidation.util.ProtoWrapper;
21 import com.google.ipc.invalidation.util.ProtoWrapper.ValidationException;
22 import com.google.ipc.invalidation.util.TextBuilder;
23 import com.google.protobuf.nano.MessageNano;
24 import com.google.protobuf.nano.InvalidProtocolBufferNanoException;
25
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.List;
29
30
31 public interface AndroidListenerProtocol {
32
33   public static final class AndroidListenerState extends ProtoWrapper {
34     public static final class RetryRegistrationState extends ProtoWrapper {
35       public static RetryRegistrationState create(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP objectId,
36           com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState exponentialBackoffState) {
37         return new RetryRegistrationState(objectId, exponentialBackoffState);
38       }
39
40       public static final RetryRegistrationState DEFAULT_INSTANCE = new RetryRegistrationState(null, null);
41
42       private final long __hazzerBits;
43       private final com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP objectId;
44       private final com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState exponentialBackoffState;
45
46       private RetryRegistrationState(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP objectId,
47           com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState exponentialBackoffState) {
48         int hazzerBits = 0;
49         this.objectId = objectId;
50         if (exponentialBackoffState != null) {
51           hazzerBits |= 0x1;
52           this.exponentialBackoffState = exponentialBackoffState;
53         } else {
54           this.exponentialBackoffState = com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState.DEFAULT_INSTANCE;
55         }
56         this.__hazzerBits = hazzerBits;
57       }
58
59       public com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP getNullableObjectId() { return objectId; }
60
61       public com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState getExponentialBackoffState() { return exponentialBackoffState; }
62       public boolean hasExponentialBackoffState() { return (0x1 & __hazzerBits) != 0; }
63
64       @Override public final boolean equals(Object obj) {
65         if (this == obj) { return true; }
66         if (!(obj instanceof RetryRegistrationState)) { return false; }
67         RetryRegistrationState other = (RetryRegistrationState) obj;
68         return __hazzerBits == other.__hazzerBits
69             && equals(objectId, other.objectId)
70             && (!hasExponentialBackoffState() || equals(exponentialBackoffState, other.exponentialBackoffState));
71       }
72
73       @Override protected int computeHashCode() {
74         int result = hash(__hazzerBits);
75         if (objectId != null) {
76           result = result * 31 + objectId.hashCode();
77         }
78         if (hasExponentialBackoffState()) {
79           result = result * 31 + exponentialBackoffState.hashCode();
80         }
81         return result;
82       }
83
84       @Override public void toCompactString(TextBuilder builder) {
85         builder.append("<RetryRegistrationState:");
86         if (objectId != null) {
87           builder.append(" object_id=").append(objectId);
88         }
89         if (hasExponentialBackoffState()) {
90           builder.append(" exponential_backoff_state=").append(exponentialBackoffState);
91         }
92         builder.append('>');
93       }
94
95       public static RetryRegistrationState parseFrom(byte[] data) throws ValidationException {
96         try {
97           return fromMessageNano(MessageNano.mergeFrom(new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState(), data));
98         } catch (InvalidProtocolBufferNanoException exception) {
99           throw new ValidationException(exception);
100         } catch (ValidationArgumentException exception) {
101           throw new ValidationException(exception.getMessage());
102         }
103       }
104
105       static RetryRegistrationState fromMessageNano(com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState message) {
106         if (message == null) { return null; }
107         return new RetryRegistrationState(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP.fromMessageNano(message.objectId),
108             com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState.fromMessageNano(message.exponentialBackoffState));
109       }
110
111       public byte[] toByteArray() {
112         return MessageNano.toByteArray(toMessageNano());
113       }
114
115       com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState toMessageNano() {
116         com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState msg = new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState();
117         msg.objectId = this.objectId != null ? objectId.toMessageNano() : null;
118         msg.exponentialBackoffState = hasExponentialBackoffState() ? exponentialBackoffState.toMessageNano() : null;
119         return msg;
120       }
121     }
122     public static AndroidListenerState create(Collection<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> registration,
123         Collection<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> retryRegistrationState,
124         Bytes clientId,
125         Integer requestCodeSeqNum) {
126       return new AndroidListenerState(registration, retryRegistrationState, clientId, requestCodeSeqNum);
127     }
128
129     public static final AndroidListenerState DEFAULT_INSTANCE = new AndroidListenerState(null, null, null, null);
130
131     private final long __hazzerBits;
132     private final List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> registration;
133     private final List<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> retryRegistrationState;
134     private final Bytes clientId;
135     private final int requestCodeSeqNum;
136
137     private AndroidListenerState(Collection<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> registration,
138         Collection<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> retryRegistrationState,
139         Bytes clientId,
140         Integer requestCodeSeqNum) {
141       int hazzerBits = 0;
142       this.registration = optional("registration", registration);
143       this.retryRegistrationState = optional("retry_registration_state", retryRegistrationState);
144       if (clientId != null) {
145         hazzerBits |= 0x1;
146         this.clientId = clientId;
147       } else {
148         this.clientId = Bytes.EMPTY_BYTES;
149       }
150       if (requestCodeSeqNum != null) {
151         hazzerBits |= 0x2;
152         this.requestCodeSeqNum = requestCodeSeqNum;
153       } else {
154         this.requestCodeSeqNum = 0;
155       }
156       this.__hazzerBits = hazzerBits;
157     }
158
159     public List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> getRegistration() { return registration; }
160
161     public List<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> getRetryRegistrationState() { return retryRegistrationState; }
162
163     public Bytes getClientId() { return clientId; }
164     public boolean hasClientId() { return (0x1 & __hazzerBits) != 0; }
165
166     public int getRequestCodeSeqNum() { return requestCodeSeqNum; }
167     public boolean hasRequestCodeSeqNum() { return (0x2 & __hazzerBits) != 0; }
168
169     @Override public final boolean equals(Object obj) {
170       if (this == obj) { return true; }
171       if (!(obj instanceof AndroidListenerState)) { return false; }
172       AndroidListenerState other = (AndroidListenerState) obj;
173       return __hazzerBits == other.__hazzerBits
174           && equals(registration, other.registration)
175           && equals(retryRegistrationState, other.retryRegistrationState)
176           && (!hasClientId() || equals(clientId, other.clientId))
177           && (!hasRequestCodeSeqNum() || requestCodeSeqNum == other.requestCodeSeqNum);
178     }
179
180     @Override protected int computeHashCode() {
181       int result = hash(__hazzerBits);
182       result = result * 31 + registration.hashCode();
183       result = result * 31 + retryRegistrationState.hashCode();
184       if (hasClientId()) {
185         result = result * 31 + clientId.hashCode();
186       }
187       if (hasRequestCodeSeqNum()) {
188         result = result * 31 + hash(requestCodeSeqNum);
189       }
190       return result;
191     }
192
193     @Override public void toCompactString(TextBuilder builder) {
194       builder.append("<AndroidListenerState:");
195       builder.append(" registration=[").append(registration).append(']');
196       builder.append(" retry_registration_state=[").append(retryRegistrationState).append(']');
197       if (hasClientId()) {
198         builder.append(" client_id=").append(clientId);
199       }
200       if (hasRequestCodeSeqNum()) {
201         builder.append(" request_code_seq_num=").append(requestCodeSeqNum);
202       }
203       builder.append('>');
204     }
205
206     public static AndroidListenerState parseFrom(byte[] data) throws ValidationException {
207       try {
208         return fromMessageNano(MessageNano.mergeFrom(new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState(), data));
209       } catch (InvalidProtocolBufferNanoException exception) {
210         throw new ValidationException(exception);
211       } catch (ValidationArgumentException exception) {
212         throw new ValidationException(exception.getMessage());
213       }
214     }
215
216     static AndroidListenerState fromMessageNano(com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState message) {
217       if (message == null) { return null; }
218       List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> registration = new ArrayList<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP>(message.registration.length);
219       for (int i = 0; i < message.registration.length; i++) {
220         registration.add(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP.fromMessageNano(message.registration[i]));
221       }
222       List<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> retryRegistrationState = new ArrayList<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState>(message.retryRegistrationState.length);
223       for (int i = 0; i < message.retryRegistrationState.length; i++) {
224         retryRegistrationState.add(com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState.fromMessageNano(message.retryRegistrationState[i]));
225       }
226       return new AndroidListenerState(registration,
227           retryRegistrationState,
228           Bytes.fromByteArray(message.clientId),
229           message.requestCodeSeqNum);
230     }
231
232     public byte[] toByteArray() {
233       return MessageNano.toByteArray(toMessageNano());
234     }
235
236     com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState toMessageNano() {
237       com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState msg = new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState();
238       msg.registration = new com.google.protos.ipc.invalidation.NanoClientProtocol.ObjectIdP[registration.size()];
239       for (int i = 0; i < msg.registration.length; i++) {
240         msg.registration[i] = registration.get(i).toMessageNano();
241       }
242       msg.retryRegistrationState = new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.AndroidListenerState.RetryRegistrationState[retryRegistrationState.size()];
243       for (int i = 0; i < msg.retryRegistrationState.length; i++) {
244         msg.retryRegistrationState[i] = retryRegistrationState.get(i).toMessageNano();
245       }
246       msg.clientId = hasClientId() ? clientId.getByteArray() : null;
247       msg.requestCodeSeqNum = hasRequestCodeSeqNum() ? requestCodeSeqNum : null;
248       return msg;
249     }
250   }
251
252   public static final class RegistrationCommand extends ProtoWrapper {
253     public static RegistrationCommand create(Boolean isRegister,
254         Collection<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> objectId,
255         Bytes clientId,
256         Boolean isDelayed) {
257       return new RegistrationCommand(isRegister, objectId, clientId, isDelayed);
258     }
259
260     public static final RegistrationCommand DEFAULT_INSTANCE = new RegistrationCommand(null, null, null, null);
261
262     private final long __hazzerBits;
263     private final boolean isRegister;
264     private final List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> objectId;
265     private final Bytes clientId;
266     private final boolean isDelayed;
267
268     private RegistrationCommand(Boolean isRegister,
269         Collection<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> objectId,
270         Bytes clientId,
271         Boolean isDelayed) {
272       int hazzerBits = 0;
273       if (isRegister != null) {
274         hazzerBits |= 0x1;
275         this.isRegister = isRegister;
276       } else {
277         this.isRegister = false;
278       }
279       this.objectId = optional("object_id", objectId);
280       if (clientId != null) {
281         hazzerBits |= 0x2;
282         this.clientId = clientId;
283       } else {
284         this.clientId = Bytes.EMPTY_BYTES;
285       }
286       if (isDelayed != null) {
287         hazzerBits |= 0x4;
288         this.isDelayed = isDelayed;
289       } else {
290         this.isDelayed = false;
291       }
292       this.__hazzerBits = hazzerBits;
293     }
294
295     public boolean getIsRegister() { return isRegister; }
296     public boolean hasIsRegister() { return (0x1 & __hazzerBits) != 0; }
297
298     public List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> getObjectId() { return objectId; }
299
300     public Bytes getClientId() { return clientId; }
301     public boolean hasClientId() { return (0x2 & __hazzerBits) != 0; }
302
303     public boolean getIsDelayed() { return isDelayed; }
304     public boolean hasIsDelayed() { return (0x4 & __hazzerBits) != 0; }
305
306     @Override public final boolean equals(Object obj) {
307       if (this == obj) { return true; }
308       if (!(obj instanceof RegistrationCommand)) { return false; }
309       RegistrationCommand other = (RegistrationCommand) obj;
310       return __hazzerBits == other.__hazzerBits
311           && (!hasIsRegister() || isRegister == other.isRegister)
312           && equals(objectId, other.objectId)
313           && (!hasClientId() || equals(clientId, other.clientId))
314           && (!hasIsDelayed() || isDelayed == other.isDelayed);
315     }
316
317     @Override protected int computeHashCode() {
318       int result = hash(__hazzerBits);
319       if (hasIsRegister()) {
320         result = result * 31 + hash(isRegister);
321       }
322       result = result * 31 + objectId.hashCode();
323       if (hasClientId()) {
324         result = result * 31 + clientId.hashCode();
325       }
326       if (hasIsDelayed()) {
327         result = result * 31 + hash(isDelayed);
328       }
329       return result;
330     }
331
332     @Override public void toCompactString(TextBuilder builder) {
333       builder.append("<RegistrationCommand:");
334       if (hasIsRegister()) {
335         builder.append(" is_register=").append(isRegister);
336       }
337       builder.append(" object_id=[").append(objectId).append(']');
338       if (hasClientId()) {
339         builder.append(" client_id=").append(clientId);
340       }
341       if (hasIsDelayed()) {
342         builder.append(" is_delayed=").append(isDelayed);
343       }
344       builder.append('>');
345     }
346
347     public static RegistrationCommand parseFrom(byte[] data) throws ValidationException {
348       try {
349         return fromMessageNano(MessageNano.mergeFrom(new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.RegistrationCommand(), data));
350       } catch (InvalidProtocolBufferNanoException exception) {
351         throw new ValidationException(exception);
352       } catch (ValidationArgumentException exception) {
353         throw new ValidationException(exception.getMessage());
354       }
355     }
356
357     static RegistrationCommand fromMessageNano(com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.RegistrationCommand message) {
358       if (message == null) { return null; }
359       List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> objectId = new ArrayList<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP>(message.objectId.length);
360       for (int i = 0; i < message.objectId.length; i++) {
361         objectId.add(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP.fromMessageNano(message.objectId[i]));
362       }
363       return new RegistrationCommand(message.isRegister,
364           objectId,
365           Bytes.fromByteArray(message.clientId),
366           message.isDelayed);
367     }
368
369     public byte[] toByteArray() {
370       return MessageNano.toByteArray(toMessageNano());
371     }
372
373     com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.RegistrationCommand toMessageNano() {
374       com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.RegistrationCommand msg = new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.RegistrationCommand();
375       msg.isRegister = hasIsRegister() ? isRegister : null;
376       msg.objectId = new com.google.protos.ipc.invalidation.NanoClientProtocol.ObjectIdP[objectId.size()];
377       for (int i = 0; i < msg.objectId.length; i++) {
378         msg.objectId[i] = objectId.get(i).toMessageNano();
379       }
380       msg.clientId = hasClientId() ? clientId.getByteArray() : null;
381       msg.isDelayed = hasIsDelayed() ? isDelayed : null;
382       return msg;
383     }
384   }
385
386   public static final class StartCommand extends ProtoWrapper {
387     public static StartCommand create(Integer clientType,
388         Bytes clientName,
389         Boolean allowSuppression) {
390       return new StartCommand(clientType, clientName, allowSuppression);
391     }
392
393     public static final StartCommand DEFAULT_INSTANCE = new StartCommand(null, null, null);
394
395     private final long __hazzerBits;
396     private final int clientType;
397     private final Bytes clientName;
398     private final boolean allowSuppression;
399
400     private StartCommand(Integer clientType,
401         Bytes clientName,
402         Boolean allowSuppression) {
403       int hazzerBits = 0;
404       if (clientType != null) {
405         hazzerBits |= 0x1;
406         this.clientType = clientType;
407       } else {
408         this.clientType = 0;
409       }
410       if (clientName != null) {
411         hazzerBits |= 0x2;
412         this.clientName = clientName;
413       } else {
414         this.clientName = Bytes.EMPTY_BYTES;
415       }
416       if (allowSuppression != null) {
417         hazzerBits |= 0x4;
418         this.allowSuppression = allowSuppression;
419       } else {
420         this.allowSuppression = false;
421       }
422       this.__hazzerBits = hazzerBits;
423     }
424
425     public int getClientType() { return clientType; }
426     public boolean hasClientType() { return (0x1 & __hazzerBits) != 0; }
427
428     public Bytes getClientName() { return clientName; }
429     public boolean hasClientName() { return (0x2 & __hazzerBits) != 0; }
430
431     public boolean getAllowSuppression() { return allowSuppression; }
432     public boolean hasAllowSuppression() { return (0x4 & __hazzerBits) != 0; }
433
434     @Override public final boolean equals(Object obj) {
435       if (this == obj) { return true; }
436       if (!(obj instanceof StartCommand)) { return false; }
437       StartCommand other = (StartCommand) obj;
438       return __hazzerBits == other.__hazzerBits
439           && (!hasClientType() || clientType == other.clientType)
440           && (!hasClientName() || equals(clientName, other.clientName))
441           && (!hasAllowSuppression() || allowSuppression == other.allowSuppression);
442     }
443
444     @Override protected int computeHashCode() {
445       int result = hash(__hazzerBits);
446       if (hasClientType()) {
447         result = result * 31 + hash(clientType);
448       }
449       if (hasClientName()) {
450         result = result * 31 + clientName.hashCode();
451       }
452       if (hasAllowSuppression()) {
453         result = result * 31 + hash(allowSuppression);
454       }
455       return result;
456     }
457
458     @Override public void toCompactString(TextBuilder builder) {
459       builder.append("<StartCommand:");
460       if (hasClientType()) {
461         builder.append(" client_type=").append(clientType);
462       }
463       if (hasClientName()) {
464         builder.append(" client_name=").append(clientName);
465       }
466       if (hasAllowSuppression()) {
467         builder.append(" allow_suppression=").append(allowSuppression);
468       }
469       builder.append('>');
470     }
471
472     public static StartCommand parseFrom(byte[] data) throws ValidationException {
473       try {
474         return fromMessageNano(MessageNano.mergeFrom(new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.StartCommand(), data));
475       } catch (InvalidProtocolBufferNanoException exception) {
476         throw new ValidationException(exception);
477       } catch (ValidationArgumentException exception) {
478         throw new ValidationException(exception.getMessage());
479       }
480     }
481
482     static StartCommand fromMessageNano(com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.StartCommand message) {
483       if (message == null) { return null; }
484       return new StartCommand(message.clientType,
485           Bytes.fromByteArray(message.clientName),
486           message.allowSuppression);
487     }
488
489     public byte[] toByteArray() {
490       return MessageNano.toByteArray(toMessageNano());
491     }
492
493     com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.StartCommand toMessageNano() {
494       com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.StartCommand msg = new com.google.protos.ipc.invalidation.NanoAndroidListenerProtocol.StartCommand();
495       msg.clientType = hasClientType() ? clientType : null;
496       msg.clientName = hasClientName() ? clientName.getByteArray() : null;
497       msg.allowSuppression = hasAllowSuppression() ? allowSuppression : null;
498       return msg;
499     }
500   }
501 }