Merge the matrix-java-sdk due to it no longer maintained. Remove thirdparty repositories.

This commit is contained in:
Anatoly Sablin
2019-07-07 23:13:59 +03:00
parent 136563c61a
commit c3262a9f25
126 changed files with 9058 additions and 8 deletions

View File

@@ -0,0 +1,88 @@
/*
* matrix-java-sdk - Matrix Client SDK for Java
* Copyright (C) 2018 Kamax Sarl
*
* https://www.kamax.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.kamax.matrix.event;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.kamax.matrix.MalformedEventException;
import io.kamax.matrix.json.GsonUtil;
import java.util.Optional;
public enum EventKey {
AuthEvents("auth_events"),
Content("content"),
Depth("depth"),
Hashes("hashes"),
Id("event_id"),
Origin("origin"),
Timestamp("origin_server_ts"),
PreviousEvents("prev_events"),
PreviousState("prev_state"),
RoomId("room_id"),
Sender("sender"),
Signatures("signatures"),
StateKey("state_key"),
Type("type"),
Membership("membership"),
Unsigned("unsigned");
private String key;
EventKey(String key) {
this.key = key;
}
public String get() {
return key;
}
public JsonObject getObj(JsonObject o) {
return findObj(o).orElseThrow(() -> new MalformedEventException(key));
}
public JsonElement getElement(JsonObject o) {
return GsonUtil.findElement(o, key).orElseThrow(() -> new MalformedEventException(key));
}
public Optional<JsonObject> findObj(JsonObject o) {
return GsonUtil.findObj(o, key);
}
public Optional<String> findString(JsonObject o) {
return GsonUtil.findString(o, key);
}
public String getString(JsonObject o) {
return findString(o).orElseThrow(() -> new MalformedEventException(key));
}
public String getStringOrNull(JsonObject o) {
return GsonUtil.getStringOrNull(o, key);
}
public long getLong(JsonObject o) {
return GsonUtil.getLong(o, key);
}
}