001    //
002    // Generated by protoc, do not edit by hand.
003    //
004    package protobuf_unittest;
005    
006    public class UnittestOptimizeFor {
007    
008       static public final class TestOptimizedForSize extends TestOptimizedForSizeBase<TestOptimizedForSize> {
009    
010          public java.util.ArrayList<String> missingFields() {
011             java.util.ArrayList<String> missingFields = super.missingFields();
012             if( hasMsg() ) {
013                try {
014                   getMsg().assertInitialized();
015                } catch (org.apache.activemq.protobuf.UninitializedMessageException e){
016                   missingFields.addAll(prefix(e.getMissingFields(),"msg."));
017                }
018             }
019             return missingFields;
020          }
021    
022          public void clear() {
023             super.clear();
024             clearI();
025             clearMsg();
026          }
027    
028          public TestOptimizedForSize clone() {
029             return new TestOptimizedForSize().mergeFrom(this);
030          }
031    
032          public TestOptimizedForSize mergeFrom(TestOptimizedForSize other) {
033             if (other.hasI()) {
034                setI(other.getI());
035             }
036             if (other.hasMsg()) {
037                if (hasMsg()) {
038                   getMsg().mergeFrom(other.getMsg());
039                } else {
040                   setMsg(other.getMsg().clone());
041                }
042             }
043             return this;
044          }
045    
046          public int serializedSizeUnframed() {
047             if (memoizedSerializedSize != -1)
048                return memoizedSerializedSize;
049    
050             int size = 0;
051             if (hasI()) {
052                size += org.apache.activemq.protobuf.CodedOutputStream.computeInt32Size(1, getI());
053             }
054             if (hasMsg()) {
055                size += computeMessageSize(19, getMsg());
056             }
057             memoizedSerializedSize = size;
058             return size;
059          }
060    
061          public TestOptimizedForSize mergeUnframed(org.apache.activemq.protobuf.CodedInputStream input) throws java.io.IOException {
062             while (true) {
063                int tag = input.readTag();
064                if ((tag & 0x07) == 4) {
065                   return this;
066                }
067                switch (tag) {
068                case 0:
069                   return this;
070                default: {
071                   break;
072                }
073                case 8:
074                   setI(input.readInt32());
075                   break;
076                case 154:
077                   if (hasMsg()) {
078                      getMsg().mergeFramed(input);
079                   } else {
080                      setMsg(new UnittestProto.ForeignMessage().mergeFramed(input));
081                   }
082                   break;
083                }
084             }
085          }
086          public void writeUnframed(org.apache.activemq.protobuf.CodedOutputStream output) throws java.io.IOException {
087             if (hasI()) {
088                output.writeInt32(1, getI());
089             }
090             if (hasMsg()) {
091                writeMessage(output, 19, getMsg());
092             }
093          }
094    
095          public static TestOptimizedForSize parseUnframed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
096             return new TestOptimizedForSize().mergeUnframed(data).checktInitialized();
097          }
098    
099          public static TestOptimizedForSize parseUnframed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
100             return new TestOptimizedForSize().mergeUnframed(data).checktInitialized();
101          }
102    
103          public static TestOptimizedForSize parseUnframed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
104             return new TestOptimizedForSize().mergeUnframed(data).checktInitialized();
105          }
106    
107          public static TestOptimizedForSize parseUnframed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
108             return new TestOptimizedForSize().mergeUnframed(data).checktInitialized();
109          }
110    
111          public static TestOptimizedForSize parseFramed(org.apache.activemq.protobuf.CodedInputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
112             return new TestOptimizedForSize().mergeFramed(data).checktInitialized();
113          }
114    
115          public static TestOptimizedForSize parseFramed(org.apache.activemq.protobuf.Buffer data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
116             return new TestOptimizedForSize().mergeFramed(data).checktInitialized();
117          }
118    
119          public static TestOptimizedForSize parseFramed(byte[] data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException {
120             return new TestOptimizedForSize().mergeFramed(data).checktInitialized();
121          }
122    
123          public static TestOptimizedForSize parseFramed(java.io.InputStream data) throws org.apache.activemq.protobuf.InvalidProtocolBufferException, java.io.IOException {
124             return new TestOptimizedForSize().mergeFramed(data).checktInitialized();
125          }
126    
127          public String toString() {
128             return toString(new java.lang.StringBuilder(), "").toString();
129          }
130    
131          public java.lang.StringBuilder toString(java.lang.StringBuilder sb, String prefix) {
132             if(  hasI() ) {
133                sb.append(prefix+"i: ");
134                sb.append(getI());
135                sb.append("\n");
136             }
137             if(  hasMsg() ) {
138                sb.append(prefix+"msg {\n");
139                getMsg().toString(sb, prefix+"  ");
140                sb.append(prefix+"}\n");
141             }
142             return sb;
143          }
144    
145          public boolean equals(Object obj) {
146             if( obj==this )
147                return true;
148             
149             if( obj==null || obj.getClass()!=TestOptimizedForSize.class )
150                return false;
151             
152             return equals((TestOptimizedForSize)obj);
153          }
154          
155          public boolean equals(TestOptimizedForSize obj) {
156             if (hasI() ^ obj.hasI() ) 
157                return false;
158             if (hasI() && ( getI()!=obj.getI() ))
159                return false;
160             if (hasMsg() ^ obj.hasMsg() ) 
161                return false;
162             if (hasMsg() && ( !getMsg().equals(obj.getMsg()) ))
163                return false;
164             return true;
165          }
166          
167          public int hashCode() {
168             int rc=692384277;
169             if (hasI()) {
170                rc ^= ( 73^getI() );
171             }
172             if (hasMsg()) {
173                rc ^= ( 77665^getMsg().hashCode() );
174             }
175             return rc;
176          }
177          
178       }
179    
180       static abstract class TestOptimizedForSizeBase<T> extends org.apache.activemq.protobuf.BaseMessage<T> {
181    
182          // optional int32 i = 1;
183          private int f_i = 0;
184          private boolean b_i;
185    
186          public boolean hasI() {
187             return this.b_i;
188          }
189    
190          public int getI() {
191             return this.f_i;
192          }
193    
194          public T setI(int i) {
195             loadAndClear();
196             this.b_i = true;
197             this.f_i = i;
198             return (T)this;
199          }
200    
201          public void clearI() {
202             loadAndClear();
203             this.b_i = false;
204             this.f_i = 0;
205          }
206    
207          // optional ForeignMessage msg = 19;
208          private UnittestProto.ForeignMessage f_msg = null;
209    
210          public boolean hasMsg() {
211             return this.f_msg!=null;
212          }
213    
214          public UnittestProto.ForeignMessage getMsg() {
215             if( this.f_msg == null ) {
216                this.f_msg = new UnittestProto.ForeignMessage();
217             }
218             return this.f_msg;
219          }
220    
221          public T setMsg(UnittestProto.ForeignMessage msg) {
222             loadAndClear();
223             this.f_msg = msg;
224             return (T)this;
225          }
226    
227          public void clearMsg() {
228             loadAndClear();
229             this.f_msg = null;
230          }
231    
232       }
233    
234    }