package org.realityforge.gwt.eventsource.client.event;

import com.google.gwt.event.shared.EventHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.realityforge.gwt.eventsource.client.EventSource;
import org.realityforge.gwt.eventsource.client.event.CloseEvent.Handler;

/**
 * Event fired when the web socket is closed.
 */
public class CloseEvent
  extends EventSourceEvent<Handler>
{
  public static final int CLOSE_NORMAL = 1000;
  public static final int CLOSE_GOING_AWAY = 1001;
  public static final int CLOSE_PROTOCOL_ERROR = 1002;
  public static final int CLOSE_UNSUPPORTED = 1003;
  public static final int CLOSE_NO_STATUS = 1005;
  public static final int CLOSE_ABNORMAL = 1006;
  public static final int CLOSE_INCONSISTENT_DATA = 1007;
  public static final int CLOSE_VIOLATES_POLICY = 1008;
  public static final int CLOSE_TOO_LARGE = 1009;
  public static final int CLOSE_EXTENSION_UNAVAILABLE = 1010;
  public static final int CLOSE_UNEXPECTED_CONDITION = 1011;

  public interface Handler
    extends EventHandler
  {
    void onCloseEvent( @Nonnull CloseEvent event );
  }

  private static final Type<Handler> TYPE = new Type<Handler>();

  public static Type<Handler> getType()
  {
    return TYPE;
  }

  private final boolean _wasClean;
  private final int _code;
  private final String _reason;

  public CloseEvent( @Nonnull final EventSource eventSource,
                     final boolean wasClean,
                     final int code,
                     @Nullable final String reason )
  {
    super( eventSource );
    _wasClean = wasClean;
    _code = code;
    _reason = reason;
  }

  public boolean wasClean()
  {
    return _wasClean;
  }

  public int getCode()
  {
    return _code;
  }

  @Nullable
  public String getReason()
  {
    return _reason;
  }

  @Override
  public Type<Handler> getAssociatedType()
  {
    return CloseEvent.getType();
  }

  @Override
  protected void dispatch( @Nonnull final Handler handler )
  {
    handler.onCloseEvent( this );
  }
}

@@ -135,42 +135,8 @@
 ll;%0A
-import javax.annotation.Nullable;%0A
 impo
@@ -394,1399 +394,334 @@
 lic 
-static final int CLOSE_NORMAL = 1000;%0A  public static final int CLOSE_GOING_AWAY = 1001;%0A  public static final int CLOSE_PROTOCOL_ERROR = 1002;%0A  public static final int CLOSE_UNSUPPORTED = 1003;%0A  public static final int CLOSE_NO_STATUS = 1005;%0A  public static final int CLOSE_ABNORMAL = 1006;%0A  public static final int CLOSE_INCONSISTENT_DATA = 1007;%0A  public static final int CLOSE_VIOLATES_POLICY = 1008;%0A  public static final int CLOSE_TOO_LARGE = 1009;%0A  public static final int CLOSE_EXTENSION_UNAVAILABLE = 1010;%0A  public static final int CLOSE_UNEXPECTED_CONDITION = 1011;%0A%0A  public interface Handler%0A    extends EventHandler%0A  %7B%0A    void onCloseEvent( @Nonnull CloseEvent event );%0A  %7D%0A%0A  private static final Type%3CHandler%3E TYPE = new Type%3CHandler%3E();%0A%0A  public static Type%3CHandler%3E getType()%0A  %7B%0A    return TYPE;%0A  %7D%0A%0A  private final boolean _wasClean;%0A  private final int _code;%0A  private final String _reason;%0A%0A  public CloseEvent( @Nonnull final EventSource eventSource,%0A                     final boolean wasClean,%0A                     final int code,%0A                     @Nullable final String reason )%0A  %7B%0A    super( eventSource );%0A    _wasClean = wasClean;%0A    _code = code;%0A    _reason = reason;%0A  %7D%0A%0A  public boolean wasClean()%0A  %7B%0A    return _wasClean;%0A  %7D%0A%0A  public int getCode()%0A  %7B%0A    return _code;%0A  %7D%0A%0A  @Nullable%0A  public String getReason()%0A  %7B%0A    return _reason
+interface Handler%0A    extends EventHandler%0A  %7B%0A    void onCloseEvent( @Nonnull CloseEvent event );%0A  %7D%0A%0A  private static final Type%3CHandler%3E TYPE = new Type%3CHandler%3E();%0A%0A  public static Type%3CHandler%3E getType()%0A  %7B%0A    return TYPE;%0A  %7D%0A%0A  public CloseEvent( @Nonnull final EventSource eventSource )%0A  %7B%0A    super( eventSource )
 ;%0A  

Remove WebSocket specific fields