001    //
002    // Generated by protoc, do not edit by hand.
003    //
004    package org.apache.activemq.store.kahadb.data;
005    
006    
007    public final class KahaAddMessageCommand extends KahaAddMessageCommandBase<KahaAddMessageCommand> implements org.apache.activemq.store.kahadb.JournalCommand<KahaAddMessageCommand> {
008    
009       public java.util.ArrayList<String> missingFields() {
010          java.util.ArrayList<String> missingFields = super.missingFields();
011          if(  !hasDestination() ) {
012             missingFields.add("destination");
013          }
014          if(  !hasMessageId() ) {
015             missingFields.add("messageId");
016          }
017          if(  !hasMessage() ) {
018             missingFields.add("message");
019          }
020          if( hasTransactionInfo() ) {
021             try {
022                getTransactionInfo().assertInitialized();
023             } catch (org.apache.activemq.protobuf.UninitializedMessageException e){
024                missingFields.addAll(prefix(e.getMissingFields(),"transaction_info."));
025             }
026          }
027          if( hasDestination() ) {
028             try {
029                getDestination().assertInitialized();
030             } catch (org.apache.activemq.protobuf.UninitializedMessageException e){
031                missingFields.addAll(prefix(e.getMissingFields(),"destination."));
032             }
033          }
034          return missingFields;
035       }
036    
037       public void clear() {
038          super.clear();
039          clearTransactionInfo();
040          clearDestination();
041          clearMessageId();
042          clearMessage();
043       }
044    
045       public KahaAddMessageCommand clone() {
046          return new KahaAddMessageCommand().mergeFrom(this);
047       }
048    
049       public KahaAddMessageCommand mergeFrom(KahaAddMessageCommand other) {
050          if (other.hasTransactionInfo()) {
051             if (hasTransactionInfo()) {
052                getTransactionInfo().mergeFrom(other.getTransactionInfo());
053             } else {
054                setTransactionInfo(other.getTransactionInfo().clone());
055             }
056          }
057          if (other.hasDestination()) {
058             if (hasDestination()) {
059                getDestination().mergeFrom(other.getDestination());
060             } else {
061                setDestination(other.getDestination().clone());
062             }
063          }
064          if (other.hasMessageId()) {
065             setMessageId(other.getMessageId());
066          }
067          if (other.hasMessage()) {
068             setMessage(other.getMessage());
069          }
070          return this;
071       }
072    
073       public int serializedSizeUnframed() {
074          if (memoizedSerializedSize != -1)
075             return memoizedSerializedSize;
076    
077          int size = 0;
078          if (hasTransactionInfo()) {
079             size += computeMessageSize(1, getTransactionInfo());
080          }
081          if (hasDestination()) {
082             size += computeMessageSize(2, getDestination());
083          }
084          if (hasMessageId()) {
085             size += org.apache.activemq.protobuf.CodedOutputStream.computeStringSize(3, getMessageId());
086          }
087          if (hasMessage()) {
088             size += org.apache.activemq.protobuf.CodedOutputStream.computeBytesSize(4, getMessage());
089          }
090          memoizedSerializedSize = size;
091          return size;
092       }
093    
094       public KahaAddMessageCommand mergeUnframed(org.apache.activemq.protobuf.CodedInputStream input) throws java.io.IOException {
095          while (true) {
096             int tag = input.readTag();
097             if ((tag & 0x07) == 4) {
098                return this;
099             }
100             switch (tag) {
101             case 0:
102                return this;
103             default: {
104                break;
105             }
106             case 10:
107                if (hasTransactionInfo()) {
108                   getTransactionInfo().mergeFramed(input);
109                } else {
110                   setTransactionInfo(new KahaTransactionInfo().mergeFramed(input));
111                }
112                break;
113             case 18:
114                if (hasDestination()) {
115                   getDestination().mergeFramed(input);
116                } else {
117                   setDestination(new KahaDestination().mergeFramed(input));
118                }
119                break;
120             case 26:
121                setMessageId(input.readString());
122                break;
123             case 34:
124                setMessage(input.readBytes());
125                break;
126             }
127          }
128       }
129       public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException {
130          if (hasTransactionInfo()) {
131             writeMessage(output, 1, getTransactionInfo());
132          }
133          if (hasDestination()) {
134             writeMessage(output, 2, getDestination());
135          }
136          if (hasMessageId()) {
137             output.writeString(3, getMessageId());
138          }
139          if (hasMessage()) {
140             output.writeBytes(4, getMessage());
141          }
142       }
143    
144       public static KahaAddMessageCommand parseUnframed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
145          return new KahaAddMessageCommand().mergeUnframed(data).checktInitialized();
146       }
147    
148       public static KahaAddMessageCommand parseUnframed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
149          return new KahaAddMessageCommand().mergeUnframed(data).checktInitialized();
150       }
151    
152       public static KahaAddMessageCommand parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
153          return new KahaAddMessageCommand().mergeUnframed(data).checktInitialized();
154       }
155    
156       public static KahaAddMessageCommand parseUnframed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
157          return new KahaAddMessageCommand().mergeUnframed(data).checktInitialized();
158       }
159    
160       public static KahaAddMessageCommand parseFramed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
161          return new KahaAddMessageCommand().mergeFramed(data).checktInitialized();
162       }
163    
164       public static KahaAddMessageCommand parseFramed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
165          return new KahaAddMessageCommand().mergeFramed(data).checktInitialized();
166       }
167    
168       public static KahaAddMessageCommand parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
169          return new KahaAddMessageCommand().mergeFramed(data).checktInitialized();
170       }
171    
172       public static KahaAddMessageCommand parseFramed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
173          return new KahaAddMessageCommand().mergeFramed(data).checktInitialized();
174       }
175    
176       public String toString() {
177          return toString(new java.lang.StringBuilder(), "").toString();
178       }
179    
180       public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
181          if(  hasTransactionInfo() ) {
182             sb.append(prefix+"transaction_info {\n");
183             getTransactionInfo().toString(sb, prefix+"  ");
184             sb.append(prefix+"}\n");
185          }
186          if(  hasDestination() ) {
187             sb.append(prefix+"destination {\n");
188             getDestination().toString(sb, prefix+"  ");
189             sb.append(prefix+"}\n");
190          }
191          if(  hasMessageId() ) {
192             sb.append(prefix+"messageId: ");
193             sb.append(getMessageId());
194             sb.append("\n");
195          }
196          if(  hasMessage() ) {
197             sb.append(prefix+"message: ");
198             sb.append(getMessage());
199             sb.append("\n");
200          }
201          return sb;
202       }
203    
204       public void visit(org.apache.activemq.store.kahadb.Visitor visitor) throws java.io.IOException {
205          visitor.visit(this);
206       }
207    
208       public KahaEntryType type() {
209          return KahaEntryType.KAHA_ADD_MESSAGE_COMMAND;
210       }
211    
212       public boolean equals(Object obj) {
213          if( obj==this )
214             return true;
215          
216          if( obj==null || obj.getClass()!=KahaAddMessageCommand.class )
217             return false;
218          
219          return equals((KahaAddMessageCommand)obj);
220       }
221       
222       public boolean equals(KahaAddMessageCommand obj) {
223          if (hasTransactionInfo() ^ obj.hasTransactionInfo() ) 
224             return false;
225          if (hasTransactionInfo() && ( !getTransactionInfo().equals(obj.getTransactionInfo()) ))
226             return false;
227          if (hasDestination() ^ obj.hasDestination() ) 
228             return false;
229          if (hasDestination() && ( !getDestination().equals(obj.getDestination()) ))
230             return false;
231          if (hasMessageId() ^ obj.hasMessageId() ) 
232             return false;
233          if (hasMessageId() && ( !getMessageId().equals(obj.getMessageId()) ))
234             return false;
235          if (hasMessage() ^ obj.hasMessage() ) 
236             return false;
237          if (hasMessage() && ( !getMessage().equals(obj.getMessage()) ))
238             return false;
239          return true;
240       }
241       
242       public int hashCode() {
243          int rc=1601475350;
244          if (hasTransactionInfo()) {
245             rc ^= ( 265667724^getTransactionInfo().hashCode() );
246          }
247          if (hasDestination()) {
248             rc ^= ( 238021614^getDestination().hashCode() );
249          }
250          if (hasMessageId()) {
251             rc ^= ( 563954530^getMessageId().hashCode() );
252          }
253          if (hasMessage()) {
254             rc ^= ( -1675388953^getMessage().hashCode() );
255          }
256          return rc;
257       }
258       
259    }
260    
261    abstract class KahaAddMessageCommandBase<T> extends org.apache.activemq.protobuf.BaseMessage<T> {
262    
263       // optional KahaTransactionInfo transaction_info = 1;
264       private KahaTransactionInfo f_transactionInfo = null;
265    
266       public boolean hasTransactionInfo() {
267          return this.f_transactionInfo!=null;
268       }
269    
270       public KahaTransactionInfo getTransactionInfo() {
271          if( this.f_transactionInfo == null ) {
272             this.f_transactionInfo = new KahaTransactionInfo();
273          }
274          return this.f_transactionInfo;
275       }
276    
277       public T setTransactionInfo(KahaTransactionInfo transactionInfo) {
278          loadAndClear();
279          this.f_transactionInfo = transactionInfo;
280          return (T)this;
281       }
282    
283       public void clearTransactionInfo() {
284          loadAndClear();
285          this.f_transactionInfo = null;
286       }
287    
288       // required KahaDestination destination = 2;
289       private KahaDestination f_destination = null;
290    
291       public boolean hasDestination() {
292          return this.f_destination!=null;
293       }
294    
295       public KahaDestination getDestination() {
296          if( this.f_destination == null ) {
297             this.f_destination = new KahaDestination();
298          }
299          return this.f_destination;
300       }
301    
302       public T setDestination(KahaDestination destination) {
303          loadAndClear();
304          this.f_destination = destination;
305          return (T)this;
306       }
307    
308       public void clearDestination() {
309          loadAndClear();
310          this.f_destination = null;
311       }
312    
313       // required string messageId = 3;
314       private java.lang.String f_messageId = null;
315       private boolean b_messageId;
316    
317       public boolean hasMessageId() {
318          return this.b_messageId;
319       }
320    
321       public java.lang.String getMessageId() {
322          return this.f_messageId;
323       }
324    
325       public T setMessageId(java.lang.String messageId) {
326          loadAndClear();
327          this.b_messageId = true;
328          this.f_messageId = messageId;
329          return (T)this;
330       }
331    
332       public void clearMessageId() {
333          loadAndClear();
334          this.b_messageId = false;
335          this.f_messageId = null;
336       }
337    
338       // required bytes message = 4;
339       private org.apache.activemq.protobuf.Buffer f_message = null;
340       private boolean b_message;
341    
342       public boolean hasMessage() {
343          return this.b_message;
344       }
345    
346       public org.apache.activemq.protobuf.Buffer getMessage() {
347          return this.f_message;
348       }
349    
350       public T setMessage(org.apache.activemq.protobuf.Buffer message) {
351          loadAndClear();
352          this.b_message = true;
353          this.f_message = message;
354          return (T)this;
355       }
356    
357       public void clearMessage() {
358          loadAndClear();
359          this.b_message = false;
360          this.f_message = null;
361       }
362    
363    }
364