class SocketAddressTemplate extends AbstractTemplate<SocketAddress> {

    @Override
    public void write(Packer packer, SocketAddress endpoint, boolean required) throws IOException {
        if (!InetSocketAddress.class.isAssignableFrom(endpoint.getClass())) {
            throw new IllegalArgumentException(endpoint.getClass().getSimpleName()
                    + " can not be encoded by " + SocketAddressTemplate.class.getSimpleName());
        }

        InetSocketAddress inetEndpoint = (InetSocketAddress) endpoint;
        packer.writeArrayBegin(2);
        packer.write(inetEndpoint.getHostName());
        packer.write(inetEndpoint.getPort());
        packer.writeArrayEnd();
    }

    private  SocketAddressTemplate();

}