2 * Copyright 2011 Google Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 // Generated by j/c/g/ipc/invalidation/common/proto_wrapper_generator
17 package com.google.ipc.invalidation.ticl.proto;
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;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.List;
31 public interface AndroidListenerProtocol {
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);
40 public static final RetryRegistrationState DEFAULT_INSTANCE = new RetryRegistrationState(null, null);
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;
46 private RetryRegistrationState(com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP objectId,
47 com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState exponentialBackoffState) {
49 this.objectId = objectId;
50 if (exponentialBackoffState != null) {
52 this.exponentialBackoffState = exponentialBackoffState;
54 this.exponentialBackoffState = com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState.DEFAULT_INSTANCE;
56 this.__hazzerBits = hazzerBits;
59 public com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP getNullableObjectId() { return objectId; }
61 public com.google.ipc.invalidation.ticl.proto.Client.ExponentialBackoffState getExponentialBackoffState() { return exponentialBackoffState; }
62 public boolean hasExponentialBackoffState() { return (0x1 & __hazzerBits) != 0; }
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));
73 @Override protected int computeHashCode() {
74 int result = hash(__hazzerBits);
75 if (objectId != null) {
76 result = result * 31 + objectId.hashCode();
78 if (hasExponentialBackoffState()) {
79 result = result * 31 + exponentialBackoffState.hashCode();
84 @Override public void toCompactString(TextBuilder builder) {
85 builder.append("<RetryRegistrationState:");
86 if (objectId != null) {
87 builder.append(" object_id=").append(objectId);
89 if (hasExponentialBackoffState()) {
90 builder.append(" exponential_backoff_state=").append(exponentialBackoffState);
95 public static RetryRegistrationState parseFrom(byte[] data) throws ValidationException {
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());
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));
111 public byte[] toByteArray() {
112 return MessageNano.toByteArray(toMessageNano());
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;
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,
125 Integer requestCodeSeqNum) {
126 return new AndroidListenerState(registration, retryRegistrationState, clientId, requestCodeSeqNum);
129 public static final AndroidListenerState DEFAULT_INSTANCE = new AndroidListenerState(null, null, null, null);
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;
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,
140 Integer requestCodeSeqNum) {
142 this.registration = optional("registration", registration);
143 this.retryRegistrationState = optional("retry_registration_state", retryRegistrationState);
144 if (clientId != null) {
146 this.clientId = clientId;
148 this.clientId = Bytes.EMPTY_BYTES;
150 if (requestCodeSeqNum != null) {
152 this.requestCodeSeqNum = requestCodeSeqNum;
154 this.requestCodeSeqNum = 0;
156 this.__hazzerBits = hazzerBits;
159 public List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> getRegistration() { return registration; }
161 public List<com.google.ipc.invalidation.ticl.proto.AndroidListenerProtocol.AndroidListenerState.RetryRegistrationState> getRetryRegistrationState() { return retryRegistrationState; }
163 public Bytes getClientId() { return clientId; }
164 public boolean hasClientId() { return (0x1 & __hazzerBits) != 0; }
166 public int getRequestCodeSeqNum() { return requestCodeSeqNum; }
167 public boolean hasRequestCodeSeqNum() { return (0x2 & __hazzerBits) != 0; }
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);
180 @Override protected int computeHashCode() {
181 int result = hash(__hazzerBits);
182 result = result * 31 + registration.hashCode();
183 result = result * 31 + retryRegistrationState.hashCode();
185 result = result * 31 + clientId.hashCode();
187 if (hasRequestCodeSeqNum()) {
188 result = result * 31 + hash(requestCodeSeqNum);
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(']');
198 builder.append(" client_id=").append(clientId);
200 if (hasRequestCodeSeqNum()) {
201 builder.append(" request_code_seq_num=").append(requestCodeSeqNum);
206 public static AndroidListenerState parseFrom(byte[] data) throws ValidationException {
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());
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]));
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]));
226 return new AndroidListenerState(registration,
227 retryRegistrationState,
228 Bytes.fromByteArray(message.clientId),
229 message.requestCodeSeqNum);
232 public byte[] toByteArray() {
233 return MessageNano.toByteArray(toMessageNano());
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();
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();
246 msg.clientId = hasClientId() ? clientId.getByteArray() : null;
247 msg.requestCodeSeqNum = hasRequestCodeSeqNum() ? requestCodeSeqNum : null;
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,
257 return new RegistrationCommand(isRegister, objectId, clientId, isDelayed);
260 public static final RegistrationCommand DEFAULT_INSTANCE = new RegistrationCommand(null, null, null, null);
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;
268 private RegistrationCommand(Boolean isRegister,
269 Collection<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> objectId,
273 if (isRegister != null) {
275 this.isRegister = isRegister;
277 this.isRegister = false;
279 this.objectId = optional("object_id", objectId);
280 if (clientId != null) {
282 this.clientId = clientId;
284 this.clientId = Bytes.EMPTY_BYTES;
286 if (isDelayed != null) {
288 this.isDelayed = isDelayed;
290 this.isDelayed = false;
292 this.__hazzerBits = hazzerBits;
295 public boolean getIsRegister() { return isRegister; }
296 public boolean hasIsRegister() { return (0x1 & __hazzerBits) != 0; }
298 public List<com.google.ipc.invalidation.ticl.proto.ClientProtocol.ObjectIdP> getObjectId() { return objectId; }
300 public Bytes getClientId() { return clientId; }
301 public boolean hasClientId() { return (0x2 & __hazzerBits) != 0; }
303 public boolean getIsDelayed() { return isDelayed; }
304 public boolean hasIsDelayed() { return (0x4 & __hazzerBits) != 0; }
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);
317 @Override protected int computeHashCode() {
318 int result = hash(__hazzerBits);
319 if (hasIsRegister()) {
320 result = result * 31 + hash(isRegister);
322 result = result * 31 + objectId.hashCode();
324 result = result * 31 + clientId.hashCode();
326 if (hasIsDelayed()) {
327 result = result * 31 + hash(isDelayed);
332 @Override public void toCompactString(TextBuilder builder) {
333 builder.append("<RegistrationCommand:");
334 if (hasIsRegister()) {
335 builder.append(" is_register=").append(isRegister);
337 builder.append(" object_id=[").append(objectId).append(']');
339 builder.append(" client_id=").append(clientId);
341 if (hasIsDelayed()) {
342 builder.append(" is_delayed=").append(isDelayed);
347 public static RegistrationCommand parseFrom(byte[] data) throws ValidationException {
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());
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]));
363 return new RegistrationCommand(message.isRegister,
365 Bytes.fromByteArray(message.clientId),
369 public byte[] toByteArray() {
370 return MessageNano.toByteArray(toMessageNano());
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();
380 msg.clientId = hasClientId() ? clientId.getByteArray() : null;
381 msg.isDelayed = hasIsDelayed() ? isDelayed : null;
386 public static final class StartCommand extends ProtoWrapper {
387 public static StartCommand create(Integer clientType,
389 Boolean allowSuppression) {
390 return new StartCommand(clientType, clientName, allowSuppression);
393 public static final StartCommand DEFAULT_INSTANCE = new StartCommand(null, null, null);
395 private final long __hazzerBits;
396 private final int clientType;
397 private final Bytes clientName;
398 private final boolean allowSuppression;
400 private StartCommand(Integer clientType,
402 Boolean allowSuppression) {
404 if (clientType != null) {
406 this.clientType = clientType;
410 if (clientName != null) {
412 this.clientName = clientName;
414 this.clientName = Bytes.EMPTY_BYTES;
416 if (allowSuppression != null) {
418 this.allowSuppression = allowSuppression;
420 this.allowSuppression = false;
422 this.__hazzerBits = hazzerBits;
425 public int getClientType() { return clientType; }
426 public boolean hasClientType() { return (0x1 & __hazzerBits) != 0; }
428 public Bytes getClientName() { return clientName; }
429 public boolean hasClientName() { return (0x2 & __hazzerBits) != 0; }
431 public boolean getAllowSuppression() { return allowSuppression; }
432 public boolean hasAllowSuppression() { return (0x4 & __hazzerBits) != 0; }
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);
444 @Override protected int computeHashCode() {
445 int result = hash(__hazzerBits);
446 if (hasClientType()) {
447 result = result * 31 + hash(clientType);
449 if (hasClientName()) {
450 result = result * 31 + clientName.hashCode();
452 if (hasAllowSuppression()) {
453 result = result * 31 + hash(allowSuppression);
458 @Override public void toCompactString(TextBuilder builder) {
459 builder.append("<StartCommand:");
460 if (hasClientType()) {
461 builder.append(" client_type=").append(clientType);
463 if (hasClientName()) {
464 builder.append(" client_name=").append(clientName);
466 if (hasAllowSuppression()) {
467 builder.append(" allow_suppression=").append(allowSuppression);
472 public static StartCommand parseFrom(byte[] data) throws ValidationException {
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());
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);
489 public byte[] toByteArray() {
490 return MessageNano.toByteArray(toMessageNano());
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;