/*
 * matrix-java-sdk - Matrix Client SDK for Java
 * Copyright (C) 2017 Maxime Dor
 *
 * https://www.kamax.io/
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

package io.kamax.matrix.json;

import com.google.gson.JsonObject;

import io.kamax.matrix.event._MatrixEvent;
import io.kamax.matrix.json.event.*;

public class MatrixJsonEventFactory {

    public static _MatrixEvent get(JsonObject obj) {
        String type = obj.get("type").getAsString();

        if ("m.room.member".contentEquals(type)) {
            return new MatrixJsonRoomMembershipEvent(obj);
        } else if ("m.room.avatar".contentEquals(type)) {
            return new MatrixJsonRoomAvatarEvent(obj);
        } else if ("m.room.name".contentEquals(type)) {
            return new MatrixJsonRoomNameEvent(obj);
        } else if ("m.room.topic".contentEquals(type)) {
            return new MatrixJsonRoomTopicEvent(obj);
        } else if ("m.room.aliases".contentEquals(type)) {
            return new MatrixJsonRoomAliasesEvent(obj);
        } else if ("m.room.message".contentEquals(type)) {
            return new MatrixJsonRoomMessageEvent(obj);
        } else {
            return new MatrixJsonEvent(obj);
        }
    }

}

@@ -824,16 +824,55 @@
 bject;%0A%0A
+import io.kamax.matrix.event.EventKey;%0A
 import i
@@ -944,16 +944,44 @@
 ent.*;%0A%0A
+import java.util.Optional;%0A%0A
 public c
@@ -1808,16 +1808,187 @@
  else %7B%0A
+            Optional%3CString%3E rId = EventKey.RoomId.findString(obj);%0A            if (rId.isPresent()) %7B%0A                return new MatrixJsonRoomEvent(obj);%0A            %7D%0A%0A
         

Add support for generic room events