소스 검색

MIgrate Signaling to kotlin data classes

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 3 년 전
부모
커밋
32a83f066f

+ 0 - 93
app/src/main/java/com/nextcloud/talk/models/json/signaling/Signaling.java

@@ -1,93 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
- *
- * 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 com.nextcloud.talk.models.json.signaling;
-
-import com.bluelinelabs.logansquare.annotation.JsonField;
-import com.bluelinelabs.logansquare.annotation.JsonObject;
-
-/**
- * Created by mdjanic on 30/10/2017.
- */
-
-@JsonObject
-public class Signaling {
-    @JsonField(name = "type")
-    String type;
-    //can be NCMessageWrapper or List<HashMap<String,String>>
-    @JsonField(name = "data")
-    Object messageWrapper;
-
-    public String getType() {
-        return this.type;
-    }
-
-    public Object getMessageWrapper() {
-        return this.messageWrapper;
-    }
-
-    public void setType(String type) {
-        this.type = type;
-    }
-
-    public void setMessageWrapper(Object messageWrapper) {
-        this.messageWrapper = messageWrapper;
-    }
-
-    public boolean equals(final Object o) {
-        if (o == this) {
-            return true;
-        }
-        if (!(o instanceof Signaling)) {
-            return false;
-        }
-        final Signaling other = (Signaling) o;
-        if (!other.canEqual((Object) this)) {
-            return false;
-        }
-        final Object this$type = this.getType();
-        final Object other$type = other.getType();
-        if (this$type == null ? other$type != null : !this$type.equals(other$type)) {
-            return false;
-        }
-        final Object this$messageWrapper = this.getMessageWrapper();
-        final Object other$messageWrapper = other.getMessageWrapper();
-
-        return this$messageWrapper == null ? other$messageWrapper == null : this$messageWrapper.equals(other$messageWrapper);
-    }
-
-    protected boolean canEqual(final Object other) {
-        return other instanceof Signaling;
-    }
-
-    public int hashCode() {
-        final int PRIME = 59;
-        int result = 1;
-        final Object $type = this.getType();
-        result = result * PRIME + ($type == null ? 43 : $type.hashCode());
-        final Object $messageWrapper = this.getMessageWrapper();
-        result = result * PRIME + ($messageWrapper == null ? 43 : $messageWrapper.hashCode());
-        return result;
-    }
-
-    public String toString() {
-        return "Signaling(type=" + this.getType() + ", messageWrapper=" + this.getMessageWrapper() + ")";
-    }
-}

+ 43 - 0
app/src/main/java/com/nextcloud/talk/models/json/signaling/Signaling.kt

@@ -0,0 +1,43 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * @author Andy Scherzinger
+ * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
+ * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
+ *
+ * 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 com.nextcloud.talk.models.json.signaling
+
+import android.os.Parcelable
+import com.bluelinelabs.logansquare.annotation.JsonField
+import com.bluelinelabs.logansquare.annotation.JsonObject
+import com.nextcloud.talk.models.json.AnyParceler
+import kotlinx.android.parcel.Parcelize
+import kotlinx.android.parcel.TypeParceler
+
+@Parcelize
+@JsonObject
+@TypeParceler<Any?, AnyParceler>
+data class Signaling(
+    @JsonField(name = ["type"])
+    var type: String? = null,
+    /** can be NCMessageWrapper or List<HashMap<String,String>> */
+    @JsonField(name = ["data"])
+    var messageWrapper: Any? = null
+) : Parcelable {
+    // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
+    constructor() : this(null, null)
+}

+ 0 - 74
app/src/main/java/com/nextcloud/talk/models/json/signaling/SignalingOCS.java

@@ -1,74 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
- *
- * 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 com.nextcloud.talk.models.json.signaling;
-
-import com.bluelinelabs.logansquare.annotation.JsonField;
-import com.bluelinelabs.logansquare.annotation.JsonObject;
-import com.nextcloud.talk.models.json.generic.GenericOCS;
-
-import java.util.List;
-
-@JsonObject
-public class SignalingOCS extends GenericOCS {
-    @JsonField(name = "data")
-    List<Signaling> signalings;
-
-    public List<Signaling> getSignalings() {
-        return this.signalings;
-    }
-
-    public void setSignalings(List<Signaling> signalings) {
-        this.signalings = signalings;
-    }
-
-    public boolean equals(final Object o) {
-        if (o == this) {
-            return true;
-        }
-        if (!(o instanceof SignalingOCS)) {
-            return false;
-        }
-        final SignalingOCS other = (SignalingOCS) o;
-        if (!other.canEqual((Object) this)) {
-            return false;
-        }
-        final Object this$signalings = this.getSignalings();
-        final Object other$signalings = other.getSignalings();
-
-        return this$signalings == null ? other$signalings == null : this$signalings.equals(other$signalings);
-    }
-
-    protected boolean canEqual(final Object other) {
-        return other instanceof SignalingOCS;
-    }
-
-    public int hashCode() {
-        final int PRIME = 59;
-        int result = 1;
-        final Object $signalings = this.getSignalings();
-        result = result * PRIME + ($signalings == null ? 43 : $signalings.hashCode());
-        return result;
-    }
-
-    public String toString() {
-        return "SignalingOCS(signalings=" + this.getSignalings() + ")";
-    }
-}

+ 40 - 0
app/src/main/java/com/nextcloud/talk/models/json/signaling/SignalingOCS.kt

@@ -0,0 +1,40 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * @author Andy Scherzinger
+ * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
+ * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
+ *
+ * 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 com.nextcloud.talk.models.json.signaling
+
+import android.os.Parcelable
+import com.bluelinelabs.logansquare.annotation.JsonField
+import com.bluelinelabs.logansquare.annotation.JsonObject
+import com.nextcloud.talk.models.json.generic.GenericMeta
+import kotlinx.android.parcel.Parcelize
+
+@Parcelize
+@JsonObject
+class SignalingOCS(
+    @JsonField(name = ["meta"])
+    var meta: GenericMeta?,
+    @JsonField(name = ["data"])
+    var signalings: List<Signaling>? = null
+) : Parcelable {
+    // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
+    constructor() : this(null, null)
+}

+ 0 - 71
app/src/main/java/com/nextcloud/talk/models/json/signaling/SignalingOverall.java

@@ -1,71 +0,0 @@
-/*
- * Nextcloud Talk application
- *
- * @author Mario Danic
- * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
- *
- * 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 com.nextcloud.talk.models.json.signaling;
-
-import com.bluelinelabs.logansquare.annotation.JsonField;
-import com.bluelinelabs.logansquare.annotation.JsonObject;
-
-@JsonObject
-public class SignalingOverall {
-    @JsonField(name = "ocs")
-    SignalingOCS ocs;
-
-    public SignalingOCS getOcs() {
-        return this.ocs;
-    }
-
-    public void setOcs(SignalingOCS ocs) {
-        this.ocs = ocs;
-    }
-
-    public boolean equals(final Object o) {
-        if (o == this) {
-            return true;
-        }
-        if (!(o instanceof SignalingOverall)) {
-            return false;
-        }
-        final SignalingOverall other = (SignalingOverall) o;
-        if (!other.canEqual((Object) this)) {
-            return false;
-        }
-        final Object this$ocs = this.getOcs();
-        final Object other$ocs = other.getOcs();
-
-        return this$ocs == null ? other$ocs == null : this$ocs.equals(other$ocs);
-    }
-
-    protected boolean canEqual(final Object other) {
-        return other instanceof SignalingOverall;
-    }
-
-    public int hashCode() {
-        final int PRIME = 59;
-        int result = 1;
-        final Object $ocs = this.getOcs();
-        result = result * PRIME + ($ocs == null ? 43 : $ocs.hashCode());
-        return result;
-    }
-
-    public String toString() {
-        return "SignalingOverall(ocs=" + this.getOcs() + ")";
-    }
-}

+ 37 - 0
app/src/main/java/com/nextcloud/talk/models/json/signaling/SignalingOverall.kt

@@ -0,0 +1,37 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * @author Andy Scherzinger
+ * Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
+ * Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
+ *
+ * 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 com.nextcloud.talk.models.json.signaling
+
+import android.os.Parcelable
+import com.bluelinelabs.logansquare.annotation.JsonField
+import com.bluelinelabs.logansquare.annotation.JsonObject
+import kotlinx.android.parcel.Parcelize
+
+@Parcelize
+@JsonObject
+class SignalingOverall(
+    @JsonField(name = ["ocs"])
+    var ocs: SignalingOCS? = null
+) : Parcelable {
+    // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
+    constructor() : this(null)
+}