Search in sources :

Example 1 with TYPE

use of org.eclipse.che.api.debug.shared.model.event.DebuggerEvent.TYPE in project che by eclipse.

the class DebuggerEventUnmarshaller method unmarshal.

@Override
public void unmarshal(Message response) throws UnmarshallerException {
    JSONObject jsonObject = JSONParser.parseStrict(response.getBody()).isObject();
    if (jsonObject == null) {
        return;
    }
    if (jsonObject.containsKey("type")) {
        String type = jsonObject.get("type").isString().stringValue();
        TYPE eventType = TYPE.valueOf(type);
        switch(eventType) {
            case SUSPEND:
                event = dtoFactory.createDtoFromJson(jsonObject.toString(), SuspendEventDto.class);
                break;
            case DISCONNECT:
                event = dtoFactory.createDtoFromJson(jsonObject.toString(), DisconnectEventDto.class);
                break;
            case BREAKPOINT_ACTIVATED:
                event = dtoFactory.createDtoFromJson(jsonObject.toString(), BreakpointActivatedEventDto.class);
                break;
            default:
                throw new UnmarshallerException("Can't parse response.", new IllegalArgumentException("Unknown debug event type: " + eventType));
        }
    }
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) SuspendEventDto(org.eclipse.che.api.debug.shared.dto.event.SuspendEventDto) DisconnectEventDto(org.eclipse.che.api.debug.shared.dto.event.DisconnectEventDto) BreakpointActivatedEventDto(org.eclipse.che.api.debug.shared.dto.event.BreakpointActivatedEventDto) UnmarshallerException(org.eclipse.che.ide.commons.exception.UnmarshallerException) TYPE(org.eclipse.che.api.debug.shared.model.event.DebuggerEvent.TYPE)

Aggregations

JSONObject (com.google.gwt.json.client.JSONObject)1 BreakpointActivatedEventDto (org.eclipse.che.api.debug.shared.dto.event.BreakpointActivatedEventDto)1 DisconnectEventDto (org.eclipse.che.api.debug.shared.dto.event.DisconnectEventDto)1 SuspendEventDto (org.eclipse.che.api.debug.shared.dto.event.SuspendEventDto)1 TYPE (org.eclipse.che.api.debug.shared.model.event.DebuggerEvent.TYPE)1 UnmarshallerException (org.eclipse.che.ide.commons.exception.UnmarshallerException)1