/** * Return the protocol for a Java interface. * <p>The correct name of the method parameters needs the <code>-parameters</code> * java compiler argument. More info at https://openjdk.java.net/jeps/118 */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage()==null?"":iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }
/** Return the protocol for a Java interface. * <p>Note that this requires that <a * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled * interface declarations, since Java 6 reflection does not provide access to * method parameter names. See Avro's build.xml for an example. */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage()==null?"":iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<String,Schema>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<Schema>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }
/** Return the protocol for a Java interface. * <p>Note that this requires that <a * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled * interface declarations, since Java 6 reflection does not provide access to * method parameter names. See Avro's build.xml for an example. */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage()==null?"":iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<String,Schema>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<Schema>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }
/** Return the protocol for a Java interface. * <p>Note that this requires that <a * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled * interface declarations, since Java 6 reflection does not provide access to * method parameter names. See Avro's build.xml for an example. */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage()==null?"":iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<String,Schema>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<Schema>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }
/** Return the protocol for a Java interface. * <p>Note that this requires that <a * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled * interface declarations, since Java 6 reflection does not provide access to * method parameter names. See Avro's build.xml for an example. */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<String,Schema>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<Schema>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }
/** Return the protocol for a Java interface. * <p>Note that this requires that <a * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled * interface declarations, since Java 6 reflection does not provide access to * method parameter names. See Avro's build.xml for an example. */ @Override public Protocol getProtocol(Class iface) { Protocol protocol = new Protocol(iface.getSimpleName(), iface.getPackage()==null?"":iface.getPackage().getName()); Map<String,Schema> names = new LinkedHashMap<String,Schema>(); Map<String,Message> messages = protocol.getMessages(); for (Method method : iface.getMethods()) if ((method.getModifiers() & Modifier.STATIC) == 0) { String name = method.getName(); if (messages.containsKey(name)) throw new AvroTypeException("Two methods with same name: "+name); messages.put(name, getMessage(method, protocol, names)); } // reverse types, since they were defined in reference order List<Schema> types = new ArrayList<Schema>(); types.addAll(names.values()); Collections.reverse(types); protocol.setTypes(types); return protocol; }