Revision 0:45acfed2777f

View differences:

.project
15 15
			<arguments>
16 16
			</arguments>
17 17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23 18
	</buildSpec>
24 19
	<natures>
25 20
		<nature>org.eclipse.jdt.core.javanature</nature>
26 21
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
27
		<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
28 22
	</natures>
29 23
</projectDescription>
README
1
To work with this project:
2

  
3
1. install protoc
4

  
5
      A. download source from http://code.google.com/p/protobuf/downloads/list and build (has also windows binary)
6
      B. try to find protoc in your package management system, (for example protobuf-compiler in Ubuntu)
7
      C. you can use protoc directly to compile the definition files into .java, .c or .cpp files
8

  
9
2. install Eclipse plugin (optional)
10

  
11
      A. install Xtext 2.3.0 from the update site http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
12
      B. install protobuf-dt from the update site http://protobuf-dt.googlecode.com/git/update-site 
13
      C. integrate plugin with protoc as shown here: https://code.google.com/p/protobuf-dt/wiki/IntegrationWithProtoc
14

  
15
3. maven integration (optional - future)
16

  
17
      A. plugin exists but available only as source code, see: https://groups.google.com/forum/?fromgroups=#!topic/protobuf/45guwE0joOM
18
         for furhter discussion: http://stackoverflow.com/questions/1578456/integrate-protocol-buffers-into-maven2-build
19

  
20

  
21

  
22

  
23

  
pom.xml
23 23
            <version>4.8.2</version>
24 24
            <scope>test</scope>
25 25
        </dependency>
26
        
27
        <dependency>
28
            <groupId>log4j</groupId>
29
            <artifactId>log4j</artifactId>
30
            <version>1.2.16</version>
31
            <scope>compile</scope>
32
        </dependency>
33 26
	</dependencies>
34 27
  
35 28
  
src/main/java/cz/agents/alite/protobuf/factory/DefaultFactoryInterfaceImpl.java
1
package cz.agents.alite.protobuf.factory;
2

  
3
import java.lang.reflect.Constructor;
4
import java.lang.reflect.Field;
5
import java.lang.reflect.InvocationTargetException;
6
import java.lang.reflect.Method;
7
import java.lang.reflect.ParameterizedType;
8

  
9
import org.apache.log4j.Logger;
10

  
11
import com.google.protobuf.Descriptors.FieldDescriptor;
12
import com.google.protobuf.InvalidProtocolBufferException;
13
import com.google.protobuf.Message;
14
import com.google.protobuf.Message.Builder;
15

  
16
/**
17
 * This is an implicit implementation of the factory interface, which can translate any Java class into 
18
 * a Protocol Buffers message as long as the object and the message adheres to restrictions described below.
19
 * Although this implementation may be useful to use in some situations (prototyping, testing, etc.) it is 
20
 * not recommended to be used extensively, because it mainly uses reflection as its machinery and therefore is
21
 * not expected to be efficient. It is also not fully tested.
22
 * 
23
 * Class/Message Requirements:
24
 * 1) The class has to have a constructor that takes all fields of the message in sequence as parameters. If some parameters are optional,
25
 *    there should be constructors with those parameters omitted. Repeated parameters were not tested at all.
26
 * 2) All fields that should be set in the message must have their public (possibly final) equivalents in the class definition, with
27
 *    exactly the same names.
28
 *    
29
 * Notice, that the factory class is created like this: 
30
 * 
31
 * 				new DefaultFactoryInterfaceImpl<SomeClassO,SomeClassM,SomeClassN>(){};
32
 * 
33
 * This is necessary to overcome Java's type erasure.
34
 * 
35
 * Don't get angry if it doesn't work - you've been warned!
36
 * 
37
 * @author stolba
38
 *
39
 * @param <O> Class of the encoded/decoded object.
40
 * @param <M> Class of the encoded/decoded protocol message.
41
 * @param <N> Class of the encoded/decoded object message.
42
 */
43
public abstract class DefaultFactoryInterfaceImpl<O,M extends Message,N extends Message> implements FactoryInterface<O,M> {
44

  
45
	private static final Logger LOGGER = Logger.getLogger(DefaultFactoryInterfaceImpl.class);
46
	
47
	final Class<O> objectClass;
48
	final Class<M> protocolClass;
49
	final Class<N> messageClass;
50
	
51
	@SuppressWarnings("unchecked")
52
	public DefaultFactoryInterfaceImpl(){
53
		
54
		//obtain actual classes of the parametrized type, works when created as an anonymous class
55
		
56
		ParameterizedType pt = (ParameterizedType)getClass().getGenericSuperclass();
57
		
58
		if(pt.getActualTypeArguments().length < 2){
59
			throw new RuntimeException("Wrong number of type arguments!");
60
		}
61
		
62
		objectClass = (Class<O>)pt.getActualTypeArguments()[0];
63
		protocolClass = (Class<M>)pt.getActualTypeArguments()[1];
64
		messageClass = (Class<N>)pt.getActualTypeArguments()[2];
65
		
66
		LOGGER.info("objectClass: " + objectClass);
67
		LOGGER.info("protocolClass: " + protocolClass);
68
		LOGGER.info("messageClass: " + messageClass);
69
	}
70
	
71
	
72
	@Override
73
	public O decode(M message) throws InvalidProtocolBufferException {
74
		
75
		Message objectMessage = null;
76
		
77
		//find the only filled field of the protocol message
78
		for(FieldDescriptor fd : message.getDescriptorForType().getFields()){
79
			LOGGER.info("name: " + fd.getName());
80
			if(fd.isOptional() && message.hasField(fd)){
81
				objectMessage = (Message)message.getField(fd);
82
				break;
83
			}
84
		}
85
		
86
		//found it?
87
		if(objectMessage == null){
88
			throw new InvalidProtocolBufferException("Trying to decode "+objectClass+" with no "+protocolClass+" defined!");
89
		}
90
		
91
		LOGGER.info("message: " + objectMessage);
92
		
93
		for(FieldDescriptor fd : objectMessage.getDescriptorForType().getFields()){
94
			LOGGER.info("name: " + fd.getName());
95
		}
96
		
97
		LOGGER.info("constructors: "+objectClass.getDeclaredConstructors().length);
98
		LOGGER.info("message fields: "+objectMessage.getAllFields().values());
99
		
100
		//try all constructors
101
		for(Constructor<?> c : objectClass.getDeclaredConstructors()){
102
			
103
			LOGGER.info("constructor param types: " + c.getParameterTypes().length);
104
			for(Class<?> pt : c.getParameterTypes()){LOGGER.info(pt);};
105
			
106
			Object o = null;
107
			
108
			try {
109
				//try to call the constructor with all defined fields provided as input, works?
110
				o = c.newInstance(objectMessage.getAllFields().values().toArray());
111
			} catch (IllegalArgumentException e) {
112
				// TODO Auto-generated catch block
113
				e.printStackTrace();
114
			} catch (InstantiationException e) {
115
				// TODO Auto-generated catch block
116
				e.printStackTrace();
117
			} catch (IllegalAccessException e) {
118
				// TODO Auto-generated catch block
119
				e.printStackTrace();
120
			} catch (InvocationTargetException e) {
121
				// TODO Auto-generated catch block
122
				e.printStackTrace();
123
			}
124
			
125
			LOGGER.info("new object: " + o);
126
			
127
			if(o != null){
128
				//it worked, return it
129
				return objectClass.cast(o);
130
			}
131
			
132
		}
133
		
134
		//no luck
135
		throw new InvalidProtocolBufferException("Could not instantiate, there is no valid constructor!");
136
	}
137

  
138
	@Override
139
	public M encode(Object object) {
140

  
141
		try {
142
			// build object message
143
			Method m = messageClass.getDeclaredMethod("newBuilder",
144
					new Class<?>[0]);
145

  
146
			Builder b = (Builder) m.invoke(messageClass, new Object[0]);
147
			LOGGER.info(b);
148

  
149
			//try to set message fields using the same class fields
150
			for (Field f : objectClass.getDeclaredFields()) {
151
				for (FieldDescriptor fd : b.getDescriptorForType().getFields()) {
152
					if (f.getName().equals(fd.getName())) {
153
						LOGGER.info("set " + fd.getName() + " to " + f.get(object));
154
						b.setField(fd, f.get(object));
155
					}
156
				}
157
			}
158

  
159
			N msg = messageClass.cast(b.build());
160
			
161
			LOGGER.info("message: " + msg);
162

  
163
			//buld protocol message
164
			Method pm = protocolClass.getDeclaredMethod("newBuilder",new Class<?>[0]);
165
			Builder pb = (Builder) pm.invoke(protocolClass, new Object[0]);
166
			LOGGER.info(b);
167
			
168
			//try to find mesasge field with the same type as is the object message
169
			for (FieldDescriptor fd : pb.getDescriptorForType().getFields()) {
170
				String typeName = fd.toProto().getTypeName();
171
				typeName = typeName.substring(typeName.lastIndexOf(".")+1);
172
				LOGGER.info(typeName + " eq? " + messageClass.getSimpleName());
173
				if(typeName.equals(messageClass.getSimpleName())){
174
					pb.setField(fd, msg);
175
				}
176
			}
177
			
178
			M pmsg = protocolClass.cast(pb.build());
179
			
180
			LOGGER.info("protobuf message: " + pmsg);
181
			
182
			return pmsg;
183

  
184
		} catch (SecurityException e) {
185
			// TODO Auto-generated catch block
186
			e.printStackTrace();
187
		} catch (NoSuchMethodException e) {
188
			// TODO Auto-generated catch block
189
			e.printStackTrace();
190
		} catch (IllegalArgumentException e) {
191
			// TODO Auto-generated catch block
192
			e.printStackTrace();
193
		} catch (IllegalAccessException e) {
194
			// TODO Auto-generated catch block
195
			e.printStackTrace();
196
		} catch (InvocationTargetException e) {
197
			// TODO Auto-generated catch block
198
			e.printStackTrace();
199
		}
200

  
201
		//no luck
202
		throw new RuntimeException("Message was not built!");
203
	}
204

  
205
	
206
	@Override
207
	public Class<O> getObjectClass() {
208
		return objectClass;
209
	}
210

  
211
}
src/main/java/cz/agents/alite/protobuf/factory/FactoryInterface.java
1
package cz.agents.alite.protobuf.factory;
2

  
3
import com.google.protobuf.InvalidProtocolBufferException;
4
import com.google.protobuf.Message;
5

  
6
/**
7
 * Implementation of this interface should encode/decode a Java object into Protocol Buffers message.
8
 * @author stolba
9
 *
10
 * @param <O> Object class that can be encoded/decoded
11
 * @param <M> Protocol Buffers message class that can be encoded/decoded
12
 */
13
public interface FactoryInterface<O,M extends Message> {
14
	
15
	public O decode(M message) throws InvalidProtocolBufferException;
16
	
17
	public M encode(Object object);
18
	
19
	/**
20
	 * Should always return the actual class of the encoded/decoded object.
21
	 * @return
22
	 */
23
	public Class<O> getObjectClass();
24

  
25
}
src/main/java/cz/agents/alite/protobuf/factory/ProtobufFactory.java
1
package cz.agents.alite.protobuf.factory;
2

  
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.io.OutputStream;
6
import java.lang.reflect.ParameterizedType;
7
import java.lang.reflect.Type;
8
import java.util.Arrays;
9
import java.util.HashMap;
10
import java.util.LinkedList;
11
import java.util.List;
12
import java.util.Map;
13

  
14
import org.apache.log4j.Logger;
15

  
16
import com.google.protobuf.Descriptors.FieldDescriptor;
17
import com.google.protobuf.InvalidProtocolBufferException;
18
import com.google.protobuf.Message;
19
import com.google.protobuf.Message.Builder;
20

  
21

  
22
/**
23
 * This class can be used to automatically encode (resp. decode) Java objects into Protocol Buffers messages and vice versa.
24
 * To do so, a FactoryInterface for the object-message pair has to be implemented. In order to be able to encode/decode multiple
25
 * object types a 'Protocol Message' has to be defined. This message should contain an optional field for each type of
26
 * object-specific message, exactly one of which should be filled in. A 'Header' message also has to be defined, containing one
27
 * field determining the size of the message to be sent. By default, the field is required to be named 'size', but the name can be
28
 * redefined using special constructor.
29
 *
30
 * There are two ways how to use the factory (which can be freely combined):
31
 * 1) Register object factories up-front and then call simple send/registerHandler methods.
32
 * 2) Provide the object factory for each call of the send/registerHandler methods separately.
33
 *
34
 * @author stolba
35
 *
36
 * @param <P> The 'Protocol Message' class.
37
 */
38
public  class ProtobufFactory <P extends Message> implements Runnable {
39

  
40
	private static final Logger LOGGER = Logger.getLogger(ProtobufFactory.class);
41

  
42
	private String HEADER_SIZE_FIELD_NAME = "size";
43

  
44
	final OutputStream output;
45
	final InputStream input;
46

  
47
	final Builder protocolBuilder;
48
	final Builder headerBuilder;
49

  
50
	FieldDescriptor headerSizeDescriptor = null;
51
	final int headerSize;
52

  
53
	final Map<Class<?>,FactoryInterface<?,P>> factoryMap = new HashMap<Class<?>,FactoryInterface<?,P>>();
54

  
55
	List<Runnable> handlers = new LinkedList<Runnable>();
56
	private P inMessage = null;
57

  
58

  
59
	/**
60
	 *
61
	 * @param input Input stream, used to receive binary encoding PB messages.
62
	 * @param output Output stream, used to send binary encoding PB messages.
63
	 * @param protocolMessage Instance of the 'Protocol Message'.
64
	 * @param headerMessage Instance of the 'Header Message'.
65
	 * @param headerSizeFieldName Redefine the name of the size field in the Header message
66
	 */
67
	public ProtobufFactory(InputStream input,OutputStream output,  P protocolMessage, Message headerMessage, String headerSizeFieldName){
68
		this(input, output, protocolMessage, headerMessage);
69

  
70
		HEADER_SIZE_FIELD_NAME = headerSizeFieldName;
71
	}
72

  
73
	/**
74
	 *
75
	 * @param input Input stream, used to receive binary encoding PB messages.
76
	 * @param output Output stream, used to send binary encoding PB messages.
77
	 * @param protocolMessage Instance of the 'Protocol Message'.
78
	 * @param headerMessage Instance of the 'Header Message'.
79
	 */
80
	public ProtobufFactory(InputStream input,OutputStream output, P protocolMessage, Message headerMessage){
81
		//builders for the messages
82
		protocolBuilder = protocolMessage.newBuilderForType();
83
		headerBuilder = headerMessage.newBuilderForType();
84

  
85
		//find descriptor of the header message field representing size of the protocol message
86
		for(FieldDescriptor fd : headerBuilder.getDescriptorForType().getFields()){
87
			LOGGER.info("full name: " + fd.getFullName());
88
			LOGGER.info("name: " + fd.getName());
89
			if(fd.getName().equals(HEADER_SIZE_FIELD_NAME)){
90
				headerSizeDescriptor = fd;
91
				break;
92
			}
93
		}
94

  
95
		if(headerSizeDescriptor == null){
96
			throw new RuntimeException("No field " + HEADER_SIZE_FIELD_NAME + " defined in headerMessage descriptor!");
97
		}
98

  
99
		//determine size of the header message
100
		headerSize = headerBuilder.clear().setField(headerSizeDescriptor,0).build().getSerializedSize();
101

  
102
		this.output = output;
103
		this.input = input;
104
	}
105

  
106
	/**
107
	 * Register an object factory.
108
	 * @param factory Factory interface to be used for enCoding/decoding.
109
	 */
110
	public <O> void registerFactory(FactoryInterface<O,P> factory){
111
		LOGGER.info("register factory for: " + factory.getObjectClass());
112
		factoryMap.put(factory.getObjectClass(), factory);
113
	}
114

  
115
	/**
116
	 * Send object to output stream using Protocol Buffers binary encoding. Some factory for the object's type must be registered before.
117
	 * @param object Object to be sent.
118
	 * @throws IOException Thrown when problems with the output stream.
119
	 */
120
	public void send(Object object) throws IOException{
121
		Message m = factoryMap.get(object.getClass()).encode(object);
122
		sendMessage(m);
123
	}
124

  
125
	/**
126
	 * Send object to output stream using Protocol Buffers binary encoding. Given factory is used to obtain
127
	 * the Protocol Buffers representation.
128
	 * @param object Object to be sent.
129
	 * @param factory Used to obtain the Protocol Buffers representation.
130
	 * @throws IOException Thrown when problems with the output stream.
131
	 */
132
	public <O,M extends Message> void send(O object, FactoryInterface<O,M> factory) throws IOException{
133
		Message m = factory.encode(object);
134
		sendMessage(m);
135
	}
136

  
137

  
138
	private void sendMessage(Message m) throws IOException{
139

  
140
		Message h = headerBuilder.clear().setField(headerSizeDescriptor, m.getSerializedSize()).build();
141

  
142
		LOGGER.info("send " + h);
143
		LOGGER.info("send header " + Arrays.toString(h.toByteArray()));
144
		output.write(h.toByteArray());
145

  
146
		LOGGER.info("send " + m);
147
		LOGGER.info("send " + Arrays.toString(m.toByteArray()));
148
		output.write(m.toByteArray());
149
		output.flush();
150
	}
151

  
152
	/**
153
	 * Register a messageHandler to receive object of type R. Some factory for the type must be registered before. It is recommended
154
	 * that the registered handler does not implement any other generic interface, because of the reflection used to determine the type
155
	 * of object it should handle. This requirements are not posed by the other handler registration method.
156
	 * @param handler
157
	 */
158
	@SuppressWarnings("unchecked")
159
	public <R> void registerMessageHandler(final ProtobufMessageHandler<R> handler){
160

  
161
		ParameterizedType pt = null;
162

  
163
		//find implemented generic interface with one parameter
164
		for(Type t : handler.getClass().getGenericInterfaces()){
165
			pt = (ParameterizedType)t;
166

  
167
			if(pt.getActualTypeArguments().length == 1){
168
				break;
169
			}
170
		}
171

  
172

  
173
		if(pt == null){
174
			throw new RuntimeException("Does not implement ProtobufMessageHandler<R>!");
175
		}
176

  
177
		//take the first argument as the type
178
		Type t = pt.getActualTypeArguments()[0];
179

  
180
		//get the factory
181
		if(!factoryMap.containsKey(t)){
182
			throw new RuntimeException("Factory for type " + t + " not registered!");
183
		}
184

  
185
		//register the handler
186
		registerMessageHandler( (FactoryInterface<R,P>)factoryMap.get(t) ,handler);
187
	}
188

  
189
	/**
190
	 * Register a messageHandler to receive object of type R. Given factory is used to decode
191
	 * the Protocol Buffers representation.
192
	 * @param factory Factory used to decode the object.
193
	 * @param handler Handler to receive a notification when object of given type is received.
194
	 */
195
	public <R> void registerMessageHandler(final FactoryInterface<R, P> factory,final ProtobufMessageHandler<R> handler) {
196

  
197
		//new handling runnable
198
		handlers.add(new Runnable() {
199
			@Override
200
			public void run() {
201

  
202
				try {
203
					handler.notify(factory.decode(inMessage));
204
				} catch (InvalidProtocolBufferException e) {
205
					LOGGER.trace("Decoding not succesfull...");
206
				} catch (Exception e){
207
					LOGGER.info("Decoding not succesfull because " + e.getMessage());
208
					e.printStackTrace();
209
				}
210

  
211
			}
212

  
213
		});
214

  
215
	}
216

  
217
	/**
218
	 * Checks the input stream for data. Call regularly to keep reading the inputs. The call is blocking if no header or message is received.
219
	 */
220
	@SuppressWarnings("unchecked")
221
	@Override
222
	public void run() {
223

  
224
		try{
225

  
226
			//check if header available
227
			if(input.available()<headerSize){
228
				LOGGER.trace("Waiting for header message of size :"+headerSize + " - available: " + input.available());
229
				return;
230
			}
231

  
232
			//read header
233
			byte[] headerBytes = new byte[headerSize];
234
			LOGGER.info("read: " + input.read(headerBytes, 0, headerSize));
235
			LOGGER.info("received header: " + Arrays.toString(headerBytes));
236
			Message inHeader = headerBuilder.clear().mergeFrom(headerBytes).build();
237

  
238
			int inMessSize = (Integer) inHeader.getField(headerSizeDescriptor);
239

  
240
			LOGGER.info("Received header:"+ inMessSize);
241
			LOGGER.info(inHeader);
242

  
243
			//wait for message
244
			LOGGER.info("Waiting for a message of size :"+inMessSize);
245
			while(input.available()<inMessSize){
246
				LOGGER.info("Waiting for a message of size :"+inMessSize);
247
				try {
248
					Thread.sleep(3000);
249
				} catch (InterruptedException e) {
250
					e.printStackTrace();
251
				}
252
			}
253

  
254
			//read message
255
			byte[] messageBytes = new byte[inMessSize];
256
			LOGGER.info("read: " + input.read(messageBytes, 0, inMessSize));
257

  
258
			LOGGER.info("received: " + Arrays.toString(messageBytes));
259

  
260
			inMessage = null;
261

  
262
			try {
263
				inMessage = (P) protocolBuilder.clear().mergeFrom(messageBytes).build();
264
			} catch (InvalidProtocolBufferException e) {
265
				LOGGER.error("Message was not received correctly - skip the rest of the iput("+input.available()+")");
266
				input.skip(input.available());
267
				e.printStackTrace();
268
			}
269

  
270
			LOGGER.info("Received message: ");
271
			LOGGER.info(inMessage);
272

  
273
			//run decoding and notify respective handlers
274
			if(inMessage != null){
275
				for(Runnable r : handlers){
276
					r.run();
277
				}
278
			}
279
			inMessage = null;
280

  
281
		}catch(IOException e){
282
			e.printStackTrace();
283
		}
284

  
285

  
286

  
287
	}
288

  
289

  
290

  
291

  
292

  
293

  
294
	/**
295
	 * Interface used to receive decoded objects originally received as byte stream by the input stream.
296
	 * @author stolba
297
	 *
298
	 * @param <R>
299
	 */
300
	public interface ProtobufMessageHandler <R>{
301
		public void notify(R object);
302
	}
303

  
304

  
305

  
306

  
307

  
308

  
309

  
310
}
src/main/java/cz/agents/alite/protobuf/generated/ProtobufMessageProtocol.java
1
// Generated by the protocol buffer compiler.  DO NOT EDIT!
2
// source: test/protobuf/Message.proto
3

  
4
package cz.agents.alite.protobuf.generated;
5

  
6
public final class ProtobufMessageProtocol {
7
  private ProtobufMessageProtocol() {}
8
  public static void registerAllExtensions(
9
      com.google.protobuf.ExtensionRegistry registry) {
10
  }
11
  public interface HeaderOrBuilder
12
      extends com.google.protobuf.MessageOrBuilder {
13
    
14
    // required int32 size = 1;
15
    boolean hasSize();
16
    int getSize();
17
  }
18
  public static final class Header extends
19
      com.google.protobuf.GeneratedMessage
20
      implements HeaderOrBuilder {
21
    // Use Header.newBuilder() to construct.
22
    private Header(Builder builder) {
23
      super(builder);
24
    }
25
    private Header(boolean noInit) {}
26
    
27
    private static final Header defaultInstance;
28
    public static Header getDefaultInstance() {
29
      return defaultInstance;
30
    }
31
    
32
    public Header getDefaultInstanceForType() {
33
      return defaultInstance;
34
    }
35
    
36
    public static final com.google.protobuf.Descriptors.Descriptor
37
        getDescriptor() {
38
      return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_Header_descriptor;
39
    }
40
    
41
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
42
        internalGetFieldAccessorTable() {
43
      return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_Header_fieldAccessorTable;
44
    }
45
    
46
    private int bitField0_;
47
    // required int32 size = 1;
48
    public static final int SIZE_FIELD_NUMBER = 1;
49
    private int size_;
50
    public boolean hasSize() {
51
      return ((bitField0_ & 0x00000001) == 0x00000001);
52
    }
53
    public int getSize() {
54
      return size_;
55
    }
56
    
57
    private void initFields() {
58
      size_ = 0;
59
    }
60
    private byte memoizedIsInitialized = -1;
61
    public final boolean isInitialized() {
62
      byte isInitialized = memoizedIsInitialized;
63
      if (isInitialized != -1) return isInitialized == 1;
64
      
65
      if (!hasSize()) {
66
        memoizedIsInitialized = 0;
67
        return false;
68
      }
69
      memoizedIsInitialized = 1;
70
      return true;
71
    }
72
    
73
    public void writeTo(com.google.protobuf.CodedOutputStream output)
74
                        throws java.io.IOException {
75
      getSerializedSize();
76
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
77
        output.writeInt32(1, size_);
78
      }
79
      getUnknownFields().writeTo(output);
80
    }
81
    
82
    private int memoizedSerializedSize = -1;
83
    public int getSerializedSize() {
84
      int size = memoizedSerializedSize;
85
      if (size != -1) return size;
86
    
87
      size = 0;
88
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
89
        size += com.google.protobuf.CodedOutputStream
90
          .computeInt32Size(1, size_);
91
      }
92
      size += getUnknownFields().getSerializedSize();
93
      memoizedSerializedSize = size;
94
      return size;
95
    }
96
    
97
    private static final long serialVersionUID = 0L;
98
    @java.lang.Override
99
    protected java.lang.Object writeReplace()
100
        throws java.io.ObjectStreamException {
101
      return super.writeReplace();
102
    }
103
    
104
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
105
        com.google.protobuf.ByteString data)
106
        throws com.google.protobuf.InvalidProtocolBufferException {
107
      return newBuilder().mergeFrom(data).buildParsed();
108
    }
109
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
110
        com.google.protobuf.ByteString data,
111
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
112
        throws com.google.protobuf.InvalidProtocolBufferException {
113
      return newBuilder().mergeFrom(data, extensionRegistry)
114
               .buildParsed();
115
    }
116
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(byte[] data)
117
        throws com.google.protobuf.InvalidProtocolBufferException {
118
      return newBuilder().mergeFrom(data).buildParsed();
119
    }
120
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
121
        byte[] data,
122
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
123
        throws com.google.protobuf.InvalidProtocolBufferException {
124
      return newBuilder().mergeFrom(data, extensionRegistry)
125
               .buildParsed();
126
    }
127
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(java.io.InputStream input)
128
        throws java.io.IOException {
129
      return newBuilder().mergeFrom(input).buildParsed();
130
    }
131
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
132
        java.io.InputStream input,
133
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
134
        throws java.io.IOException {
135
      return newBuilder().mergeFrom(input, extensionRegistry)
136
               .buildParsed();
137
    }
138
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseDelimitedFrom(java.io.InputStream input)
139
        throws java.io.IOException {
140
      Builder builder = newBuilder();
141
      if (builder.mergeDelimitedFrom(input)) {
142
        return builder.buildParsed();
143
      } else {
144
        return null;
145
      }
146
    }
147
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseDelimitedFrom(
148
        java.io.InputStream input,
149
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
150
        throws java.io.IOException {
151
      Builder builder = newBuilder();
152
      if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
153
        return builder.buildParsed();
154
      } else {
155
        return null;
156
      }
157
    }
158
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
159
        com.google.protobuf.CodedInputStream input)
160
        throws java.io.IOException {
161
      return newBuilder().mergeFrom(input).buildParsed();
162
    }
163
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header parseFrom(
164
        com.google.protobuf.CodedInputStream input,
165
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
166
        throws java.io.IOException {
167
      return newBuilder().mergeFrom(input, extensionRegistry)
168
               .buildParsed();
169
    }
170
    
171
    public static Builder newBuilder() { return Builder.create(); }
172
    public Builder newBuilderForType() { return newBuilder(); }
173
    public static Builder newBuilder(cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header prototype) {
174
      return newBuilder().mergeFrom(prototype);
175
    }
176
    public Builder toBuilder() { return newBuilder(this); }
177
    
178
    @java.lang.Override
179
    protected Builder newBuilderForType(
180
        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
181
      Builder builder = new Builder(parent);
182
      return builder;
183
    }
184
    public static final class Builder extends
185
        com.google.protobuf.GeneratedMessage.Builder<Builder>
186
       implements cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.HeaderOrBuilder {
187
      public static final com.google.protobuf.Descriptors.Descriptor
188
          getDescriptor() {
189
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_Header_descriptor;
190
      }
191
      
192
      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
193
          internalGetFieldAccessorTable() {
194
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_Header_fieldAccessorTable;
195
      }
196
      
197
      // Construct using cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header.newBuilder()
198
      private Builder() {
199
        maybeForceBuilderInitialization();
200
      }
201
      
202
      private Builder(BuilderParent parent) {
203
        super(parent);
204
        maybeForceBuilderInitialization();
205
      }
206
      private void maybeForceBuilderInitialization() {
207
        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
208
        }
209
      }
210
      private static Builder create() {
211
        return new Builder();
212
      }
213
      
214
      public Builder clear() {
215
        super.clear();
216
        size_ = 0;
217
        bitField0_ = (bitField0_ & ~0x00000001);
218
        return this;
219
      }
220
      
221
      public Builder clone() {
222
        return create().mergeFrom(buildPartial());
223
      }
224
      
225
      public com.google.protobuf.Descriptors.Descriptor
226
          getDescriptorForType() {
227
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header.getDescriptor();
228
      }
229
      
230
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header getDefaultInstanceForType() {
231
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header.getDefaultInstance();
232
      }
233
      
234
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header build() {
235
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header result = buildPartial();
236
        if (!result.isInitialized()) {
237
          throw newUninitializedMessageException(result);
238
        }
239
        return result;
240
      }
241
      
242
      private cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header buildParsed()
243
          throws com.google.protobuf.InvalidProtocolBufferException {
244
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header result = buildPartial();
245
        if (!result.isInitialized()) {
246
          throw newUninitializedMessageException(
247
            result).asInvalidProtocolBufferException();
248
        }
249
        return result;
250
      }
251
      
252
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header buildPartial() {
253
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header result = new cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header(this);
254
        int from_bitField0_ = bitField0_;
255
        int to_bitField0_ = 0;
256
        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
257
          to_bitField0_ |= 0x00000001;
258
        }
259
        result.size_ = size_;
260
        result.bitField0_ = to_bitField0_;
261
        onBuilt();
262
        return result;
263
      }
264
      
265
      public Builder mergeFrom(com.google.protobuf.Message other) {
266
        if (other instanceof cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header) {
267
          return mergeFrom((cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header)other);
268
        } else {
269
          super.mergeFrom(other);
270
          return this;
271
        }
272
      }
273
      
274
      public Builder mergeFrom(cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header other) {
275
        if (other == cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.Header.getDefaultInstance()) return this;
276
        if (other.hasSize()) {
277
          setSize(other.getSize());
278
        }
279
        this.mergeUnknownFields(other.getUnknownFields());
280
        return this;
281
      }
282
      
283
      public final boolean isInitialized() {
284
        if (!hasSize()) {
285
          
286
          return false;
287
        }
288
        return true;
289
      }
290
      
291
      public Builder mergeFrom(
292
          com.google.protobuf.CodedInputStream input,
293
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
294
          throws java.io.IOException {
295
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
296
          com.google.protobuf.UnknownFieldSet.newBuilder(
297
            this.getUnknownFields());
298
        while (true) {
299
          int tag = input.readTag();
300
          switch (tag) {
301
            case 0:
302
              this.setUnknownFields(unknownFields.build());
303
              onChanged();
304
              return this;
305
            default: {
306
              if (!parseUnknownField(input, unknownFields,
307
                                     extensionRegistry, tag)) {
308
                this.setUnknownFields(unknownFields.build());
309
                onChanged();
310
                return this;
311
              }
312
              break;
313
            }
314
            case 8: {
315
              bitField0_ |= 0x00000001;
316
              size_ = input.readInt32();
317
              break;
318
            }
319
          }
320
        }
321
      }
322
      
323
      private int bitField0_;
324
      
325
      // required int32 size = 1;
326
      private int size_ ;
327
      public boolean hasSize() {
328
        return ((bitField0_ & 0x00000001) == 0x00000001);
329
      }
330
      public int getSize() {
331
        return size_;
332
      }
333
      public Builder setSize(int value) {
334
        bitField0_ |= 0x00000001;
335
        size_ = value;
336
        onChanged();
337
        return this;
338
      }
339
      public Builder clearSize() {
340
        bitField0_ = (bitField0_ & ~0x00000001);
341
        size_ = 0;
342
        onChanged();
343
        return this;
344
      }
345
      
346
      // @@protoc_insertion_point(builder_scope:test.Header)
347
    }
348
    
349
    static {
350
      defaultInstance = new Header(true);
351
      defaultInstance.initFields();
352
    }
353
    
354
    // @@protoc_insertion_point(class_scope:test.Header)
355
  }
356
  
357
  public interface ProtobufMessageOrBuilder
358
      extends com.google.protobuf.MessageOrBuilder {
359
    
360
    // optional .test.Point3dMessage point = 2;
361
    boolean hasPoint();
362
    cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage getPoint();
363
    cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder getPointOrBuilder();
364
    
365
    // optional .test.RadarMessage radar = 3;
366
    boolean hasRadar();
367
    cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage getRadar();
368
    cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessageOrBuilder getRadarOrBuilder();
369
  }
370
  public static final class ProtobufMessage extends
371
      com.google.protobuf.GeneratedMessage
372
      implements ProtobufMessageOrBuilder {
373
    // Use ProtobufMessage.newBuilder() to construct.
374
    private ProtobufMessage(Builder builder) {
375
      super(builder);
376
    }
377
    private ProtobufMessage(boolean noInit) {}
378
    
379
    private static final ProtobufMessage defaultInstance;
380
    public static ProtobufMessage getDefaultInstance() {
381
      return defaultInstance;
382
    }
383
    
384
    public ProtobufMessage getDefaultInstanceForType() {
385
      return defaultInstance;
386
    }
387
    
388
    public static final com.google.protobuf.Descriptors.Descriptor
389
        getDescriptor() {
390
      return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_ProtobufMessage_descriptor;
391
    }
392
    
393
    protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
394
        internalGetFieldAccessorTable() {
395
      return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_ProtobufMessage_fieldAccessorTable;
396
    }
397
    
398
    private int bitField0_;
399
    // optional .test.Point3dMessage point = 2;
400
    public static final int POINT_FIELD_NUMBER = 2;
401
    private cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage point_;
402
    public boolean hasPoint() {
403
      return ((bitField0_ & 0x00000001) == 0x00000001);
404
    }
405
    public cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage getPoint() {
406
      return point_;
407
    }
408
    public cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder getPointOrBuilder() {
409
      return point_;
410
    }
411
    
412
    // optional .test.RadarMessage radar = 3;
413
    public static final int RADAR_FIELD_NUMBER = 3;
414
    private cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage radar_;
415
    public boolean hasRadar() {
416
      return ((bitField0_ & 0x00000002) == 0x00000002);
417
    }
418
    public cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage getRadar() {
419
      return radar_;
420
    }
421
    public cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessageOrBuilder getRadarOrBuilder() {
422
      return radar_;
423
    }
424
    
425
    private void initFields() {
426
      point_ = cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.getDefaultInstance();
427
      radar_ = cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.getDefaultInstance();
428
    }
429
    private byte memoizedIsInitialized = -1;
430
    public final boolean isInitialized() {
431
      byte isInitialized = memoizedIsInitialized;
432
      if (isInitialized != -1) return isInitialized == 1;
433
      
434
      if (hasPoint()) {
435
        if (!getPoint().isInitialized()) {
436
          memoizedIsInitialized = 0;
437
          return false;
438
        }
439
      }
440
      if (hasRadar()) {
441
        if (!getRadar().isInitialized()) {
442
          memoizedIsInitialized = 0;
443
          return false;
444
        }
445
      }
446
      memoizedIsInitialized = 1;
447
      return true;
448
    }
449
    
450
    public void writeTo(com.google.protobuf.CodedOutputStream output)
451
                        throws java.io.IOException {
452
      getSerializedSize();
453
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
454
        output.writeMessage(2, point_);
455
      }
456
      if (((bitField0_ & 0x00000002) == 0x00000002)) {
457
        output.writeMessage(3, radar_);
458
      }
459
      getUnknownFields().writeTo(output);
460
    }
461
    
462
    private int memoizedSerializedSize = -1;
463
    public int getSerializedSize() {
464
      int size = memoizedSerializedSize;
465
      if (size != -1) return size;
466
    
467
      size = 0;
468
      if (((bitField0_ & 0x00000001) == 0x00000001)) {
469
        size += com.google.protobuf.CodedOutputStream
470
          .computeMessageSize(2, point_);
471
      }
472
      if (((bitField0_ & 0x00000002) == 0x00000002)) {
473
        size += com.google.protobuf.CodedOutputStream
474
          .computeMessageSize(3, radar_);
475
      }
476
      size += getUnknownFields().getSerializedSize();
477
      memoizedSerializedSize = size;
478
      return size;
479
    }
480
    
481
    private static final long serialVersionUID = 0L;
482
    @java.lang.Override
483
    protected java.lang.Object writeReplace()
484
        throws java.io.ObjectStreamException {
485
      return super.writeReplace();
486
    }
487
    
488
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
489
        com.google.protobuf.ByteString data)
490
        throws com.google.protobuf.InvalidProtocolBufferException {
491
      return newBuilder().mergeFrom(data).buildParsed();
492
    }
493
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
494
        com.google.protobuf.ByteString data,
495
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
496
        throws com.google.protobuf.InvalidProtocolBufferException {
497
      return newBuilder().mergeFrom(data, extensionRegistry)
498
               .buildParsed();
499
    }
500
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(byte[] data)
501
        throws com.google.protobuf.InvalidProtocolBufferException {
502
      return newBuilder().mergeFrom(data).buildParsed();
503
    }
504
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
505
        byte[] data,
506
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
507
        throws com.google.protobuf.InvalidProtocolBufferException {
508
      return newBuilder().mergeFrom(data, extensionRegistry)
509
               .buildParsed();
510
    }
511
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(java.io.InputStream input)
512
        throws java.io.IOException {
513
      return newBuilder().mergeFrom(input).buildParsed();
514
    }
515
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
516
        java.io.InputStream input,
517
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
518
        throws java.io.IOException {
519
      return newBuilder().mergeFrom(input, extensionRegistry)
520
               .buildParsed();
521
    }
522
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseDelimitedFrom(java.io.InputStream input)
523
        throws java.io.IOException {
524
      Builder builder = newBuilder();
525
      if (builder.mergeDelimitedFrom(input)) {
526
        return builder.buildParsed();
527
      } else {
528
        return null;
529
      }
530
    }
531
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseDelimitedFrom(
532
        java.io.InputStream input,
533
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
534
        throws java.io.IOException {
535
      Builder builder = newBuilder();
536
      if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
537
        return builder.buildParsed();
538
      } else {
539
        return null;
540
      }
541
    }
542
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
543
        com.google.protobuf.CodedInputStream input)
544
        throws java.io.IOException {
545
      return newBuilder().mergeFrom(input).buildParsed();
546
    }
547
    public static cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage parseFrom(
548
        com.google.protobuf.CodedInputStream input,
549
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
550
        throws java.io.IOException {
551
      return newBuilder().mergeFrom(input, extensionRegistry)
552
               .buildParsed();
553
    }
554
    
555
    public static Builder newBuilder() { return Builder.create(); }
556
    public Builder newBuilderForType() { return newBuilder(); }
557
    public static Builder newBuilder(cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage prototype) {
558
      return newBuilder().mergeFrom(prototype);
559
    }
560
    public Builder toBuilder() { return newBuilder(this); }
561
    
562
    @java.lang.Override
563
    protected Builder newBuilderForType(
564
        com.google.protobuf.GeneratedMessage.BuilderParent parent) {
565
      Builder builder = new Builder(parent);
566
      return builder;
567
    }
568
    public static final class Builder extends
569
        com.google.protobuf.GeneratedMessage.Builder<Builder>
570
       implements cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessageOrBuilder {
571
      public static final com.google.protobuf.Descriptors.Descriptor
572
          getDescriptor() {
573
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_ProtobufMessage_descriptor;
574
      }
575
      
576
      protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
577
          internalGetFieldAccessorTable() {
578
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.internal_static_test_ProtobufMessage_fieldAccessorTable;
579
      }
580
      
581
      // Construct using cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage.newBuilder()
582
      private Builder() {
583
        maybeForceBuilderInitialization();
584
      }
585
      
586
      private Builder(BuilderParent parent) {
587
        super(parent);
588
        maybeForceBuilderInitialization();
589
      }
590
      private void maybeForceBuilderInitialization() {
591
        if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
592
          getPointFieldBuilder();
593
          getRadarFieldBuilder();
594
        }
595
      }
596
      private static Builder create() {
597
        return new Builder();
598
      }
599
      
600
      public Builder clear() {
601
        super.clear();
602
        if (pointBuilder_ == null) {
603
          point_ = cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.getDefaultInstance();
604
        } else {
605
          pointBuilder_.clear();
606
        }
607
        bitField0_ = (bitField0_ & ~0x00000001);
608
        if (radarBuilder_ == null) {
609
          radar_ = cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.getDefaultInstance();
610
        } else {
611
          radarBuilder_.clear();
612
        }
613
        bitField0_ = (bitField0_ & ~0x00000002);
614
        return this;
615
      }
616
      
617
      public Builder clone() {
618
        return create().mergeFrom(buildPartial());
619
      }
620
      
621
      public com.google.protobuf.Descriptors.Descriptor
622
          getDescriptorForType() {
623
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage.getDescriptor();
624
      }
625
      
626
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage getDefaultInstanceForType() {
627
        return cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage.getDefaultInstance();
628
      }
629
      
630
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage build() {
631
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage result = buildPartial();
632
        if (!result.isInitialized()) {
633
          throw newUninitializedMessageException(result);
634
        }
635
        return result;
636
      }
637
      
638
      private cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage buildParsed()
639
          throws com.google.protobuf.InvalidProtocolBufferException {
640
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage result = buildPartial();
641
        if (!result.isInitialized()) {
642
          throw newUninitializedMessageException(
643
            result).asInvalidProtocolBufferException();
644
        }
645
        return result;
646
      }
647
      
648
      public cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage buildPartial() {
649
        cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage result = new cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage(this);
650
        int from_bitField0_ = bitField0_;
651
        int to_bitField0_ = 0;
652
        if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
653
          to_bitField0_ |= 0x00000001;
654
        }
655
        if (pointBuilder_ == null) {
656
          result.point_ = point_;
657
        } else {
658
          result.point_ = pointBuilder_.build();
659
        }
660
        if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
661
          to_bitField0_ |= 0x00000002;
662
        }
663
        if (radarBuilder_ == null) {
664
          result.radar_ = radar_;
665
        } else {
666
          result.radar_ = radarBuilder_.build();
667
        }
668
        result.bitField0_ = to_bitField0_;
669
        onBuilt();
670
        return result;
671
      }
672
      
673
      public Builder mergeFrom(com.google.protobuf.Message other) {
674
        if (other instanceof cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage) {
675
          return mergeFrom((cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage)other);
676
        } else {
677
          super.mergeFrom(other);
678
          return this;
679
        }
680
      }
681
      
682
      public Builder mergeFrom(cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage other) {
683
        if (other == cz.agents.alite.protobuf.generated.ProtobufMessageProtocol.ProtobufMessage.getDefaultInstance()) return this;
684
        if (other.hasPoint()) {
685
          mergePoint(other.getPoint());
686
        }
687
        if (other.hasRadar()) {
688
          mergeRadar(other.getRadar());
689
        }
690
        this.mergeUnknownFields(other.getUnknownFields());
691
        return this;
692
      }
693
      
694
      public final boolean isInitialized() {
695
        if (hasPoint()) {
696
          if (!getPoint().isInitialized()) {
697
            
698
            return false;
699
          }
700
        }
701
        if (hasRadar()) {
702
          if (!getRadar().isInitialized()) {
703
            
704
            return false;
705
          }
706
        }
707
        return true;
708
      }
709
      
710
      public Builder mergeFrom(
711
          com.google.protobuf.CodedInputStream input,
712
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
713
          throws java.io.IOException {
714
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
715
          com.google.protobuf.UnknownFieldSet.newBuilder(
716
            this.getUnknownFields());
717
        while (true) {
718
          int tag = input.readTag();
719
          switch (tag) {
720
            case 0:
721
              this.setUnknownFields(unknownFields.build());
722
              onChanged();
723
              return this;
724
            default: {
725
              if (!parseUnknownField(input, unknownFields,
726
                                     extensionRegistry, tag)) {
727
                this.setUnknownFields(unknownFields.build());
728
                onChanged();
729
                return this;
730
              }
731
              break;
732
            }
733
            case 18: {
734
              cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder subBuilder = cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.newBuilder();
735
              if (hasPoint()) {
736
                subBuilder.mergeFrom(getPoint());
737
              }
738
              input.readMessage(subBuilder, extensionRegistry);
739
              setPoint(subBuilder.buildPartial());
740
              break;
741
            }
742
            case 26: {
743
              cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.Builder subBuilder = cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.newBuilder();
744
              if (hasRadar()) {
745
                subBuilder.mergeFrom(getRadar());
746
              }
747
              input.readMessage(subBuilder, extensionRegistry);
748
              setRadar(subBuilder.buildPartial());
749
              break;
750
            }
751
          }
752
        }
753
      }
754
      
755
      private int bitField0_;
756
      
757
      // optional .test.Point3dMessage point = 2;
758
      private cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage point_ = cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.getDefaultInstance();
759
      private com.google.protobuf.SingleFieldBuilder<
760
          cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder> pointBuilder_;
761
      public boolean hasPoint() {
762
        return ((bitField0_ & 0x00000001) == 0x00000001);
763
      }
764
      public cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage getPoint() {
765
        if (pointBuilder_ == null) {
766
          return point_;
767
        } else {
768
          return pointBuilder_.getMessage();
769
        }
770
      }
771
      public Builder setPoint(cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage value) {
772
        if (pointBuilder_ == null) {
773
          if (value == null) {
774
            throw new NullPointerException();
775
          }
776
          point_ = value;
777
          onChanged();
778
        } else {
779
          pointBuilder_.setMessage(value);
780
        }
781
        bitField0_ |= 0x00000001;
782
        return this;
783
      }
784
      public Builder setPoint(
785
          cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder builderForValue) {
786
        if (pointBuilder_ == null) {
787
          point_ = builderForValue.build();
788
          onChanged();
789
        } else {
790
          pointBuilder_.setMessage(builderForValue.build());
791
        }
792
        bitField0_ |= 0x00000001;
793
        return this;
794
      }
795
      public Builder mergePoint(cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage value) {
796
        if (pointBuilder_ == null) {
797
          if (((bitField0_ & 0x00000001) == 0x00000001) &&
798
              point_ != cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.getDefaultInstance()) {
799
            point_ =
800
              cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.newBuilder(point_).mergeFrom(value).buildPartial();
801
          } else {
802
            point_ = value;
803
          }
804
          onChanged();
805
        } else {
806
          pointBuilder_.mergeFrom(value);
807
        }
808
        bitField0_ |= 0x00000001;
809
        return this;
810
      }
811
      public Builder clearPoint() {
812
        if (pointBuilder_ == null) {
813
          point_ = cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.getDefaultInstance();
814
          onChanged();
815
        } else {
816
          pointBuilder_.clear();
817
        }
818
        bitField0_ = (bitField0_ & ~0x00000001);
819
        return this;
820
      }
821
      public cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder getPointBuilder() {
822
        bitField0_ |= 0x00000001;
823
        onChanged();
824
        return getPointFieldBuilder().getBuilder();
825
      }
826
      public cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder getPointOrBuilder() {
827
        if (pointBuilder_ != null) {
828
          return pointBuilder_.getMessageOrBuilder();
829
        } else {
830
          return point_;
831
        }
832
      }
833
      private com.google.protobuf.SingleFieldBuilder<
834
          cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder> 
835
          getPointFieldBuilder() {
836
        if (pointBuilder_ == null) {
837
          pointBuilder_ = new com.google.protobuf.SingleFieldBuilder<
838
              cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessage.Builder, cz.agents.alite.protobuf.generated.ProtobufPoint3d.Point3dMessageOrBuilder>(
839
                  point_,
840
                  getParentForChildren(),
841
                  isClean());
842
          point_ = null;
843
        }
844
        return pointBuilder_;
845
      }
846
      
847
      // optional .test.RadarMessage radar = 3;
848
      private cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage radar_ = cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.getDefaultInstance();
849
      private com.google.protobuf.SingleFieldBuilder<
850
          cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage, cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.Builder, cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessageOrBuilder> radarBuilder_;
851
      public boolean hasRadar() {
852
        return ((bitField0_ & 0x00000002) == 0x00000002);
853
      }
854
      public cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage getRadar() {
855
        if (radarBuilder_ == null) {
856
          return radar_;
857
        } else {
858
          return radarBuilder_.getMessage();
859
        }
860
      }
861
      public Builder setRadar(cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage value) {
862
        if (radarBuilder_ == null) {
863
          if (value == null) {
864
            throw new NullPointerException();
865
          }
866
          radar_ = value;
867
          onChanged();
868
        } else {
869
          radarBuilder_.setMessage(value);
870
        }
871
        bitField0_ |= 0x00000002;
872
        return this;
873
      }
874
      public Builder setRadar(
875
          cz.agents.alite.protobuf.generated.ProtobufRadar.RadarMessage.Builder builderForValue) {
876
        if (radarBuilder_ == null) {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff