* 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;
}