com.threerings.presents.tools.decoder.tmpl Maven / Gradle / Ivy
package {{package}};
{{#importGroups}}
{{#this}}
import {{this}};
{{/this}}
{{/importGroups}}
/**
* Dispatches calls to a {@link {{name}}Receiver} instance.
*/
public class {{name}}Decoder extends InvocationDecoder
{
/** The generated hash code used to identify this receiver class. */
public static final String RECEIVER_CODE = "{{receiver_code}}";
{{#methods}}
/** The method id used to dispatch {@link {{name}}Receiver#{{method.name}}}
* notifications. */
public static final int {{code}} = {{-index}};
{{/methods}}
/**
* Creates a decoder that may be registered to dispatch invocation
* service notifications to the specified receiver.
*/
public {{name}}Decoder ({{name}}Receiver receiver)
{
this.receiver = receiver;
}
@Override
public String getReceiverCode ()
{
return RECEIVER_CODE;
}
@Override
public void dispatchNotification (int methodId, Object[] args)
{
switch (methodId) {
{{#methods}}
case {{code}}:
(({{name}}Receiver)receiver).{{method.name}}(
{{getUnwrappedArgListAsListeners}}
);
return;
{{/methods}}
default:
super.dispatchNotification(methodId, args);
return;
}
}
}