io.github.aleksas.arduino.simplerpc.Protocol Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of arduino-simple-rpc Show documentation
Show all versions of arduino-simple-rpc Show documentation
Arduino simpleRPC API client library
package io.github.aleksas.arduino.simplerpc;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Simple RPC protocol class.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
class Protocol {
/**
* Java type name of a C object type.
* @param type C object type.
* @return Java type name.
*/
public static String TypeName(Object obj_type) {
List types = new ArrayList();
if (obj_type == null) {
return "";
} else if (obj_type instanceof Tuple) {
Tuple tuple = (Tuple) obj_type;
for (Object object: tuple.toList())
types.add(TypeName(object));
return "(" + String.join(", ", types) + ")";
} else if (obj_type instanceof List){
List