Prechádzať zdrojové kódy

Merge pull request #5399 from nextcloud/extractArbitraryDataSet

extract ArbitraryDataSet class
Tobias Kaminsky 5 rokov pred
rodič
commit
c5be0ad7e4

+ 1 - 1
scripts/analysis/findbugs-results.txt

@@ -1 +1 @@
-387
+386

+ 8 - 58
src/main/java/com/owncloud/android/datamodel/ArbitraryDataProvider.java

@@ -1,4 +1,4 @@
-/**
+/*
  * Nextcloud Android client application
  *
  * Copyright (C) 2017 Tobias Kaminsky
@@ -9,12 +9,12 @@
  * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  * License as published by the Free Software Foundation; either
  * version 3 of the License, or any later version.
- * <p>
+ *
  * 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.
- * <p>
+ *
  * 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/>.
  */
@@ -29,8 +29,6 @@ import android.net.Uri;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.lib.common.utils.Log_OC;
 
-import java.util.List;
-
 import androidx.annotation.NonNull;
 
 /**
@@ -61,15 +59,6 @@ public class ArbitraryDataProvider {
         );
     }
 
-    public int deleteForKeyWhereAccountNotIn(List<String> accounts, String key) {
-        return contentResolver.delete(
-                ProviderMeta.ProviderTableMeta.CONTENT_URI_ARBITRARY_DATA,
-                ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_CLOUD_ID + " NOT IN (?) AND " +
-                        ProviderMeta.ProviderTableMeta.ARBITRARY_DATA_KEY + "= ?",
-                new String[]{String.valueOf(accounts), key}
-        );
-    }
-
     public void storeOrUpdateKeyValue(String accountName, String key, long newValue) {
         storeOrUpdateKeyValue(accountName, key, String.valueOf(newValue));
     }
@@ -112,11 +101,11 @@ public class ArbitraryDataProvider {
         }
     }
 
-    public Long getLongValue(String accountName, String key) {
+    Long getLongValue(String accountName, String key) {
         String value = getValue(accountName, key);
 
         if (value.isEmpty()) {
-            return -1l;
+            return -1L;
         } else {
             return Long.valueOf(value);
         }
@@ -138,9 +127,9 @@ public class ArbitraryDataProvider {
     /**
      * returns integer if found else -1
      *
-     * @param accountName
-     * @param key
-     * @return
+     * @param accountName name of account
+     * @param key key to get value for
+     * @return Integer specified by account and key
      */
     public Integer getIntegerValue(String accountName, String key) {
         String value = getValue(accountName, key);
@@ -152,17 +141,6 @@ public class ArbitraryDataProvider {
         }
     }
 
-    /**
-     * returns integer if found else -1
-     *
-     * @param account
-     * @param key
-     * @return
-     */
-    public Integer getIntegerValue(Account account, String key) {
-        return getIntegerValue(account.name, key);
-    }
-
     /**
      * Returns stored value as string or empty string
      * @return string if value found or empty string
@@ -238,34 +216,6 @@ public class ArbitraryDataProvider {
     }
 
 
-    public class ArbitraryDataSet {
-        private int id;
-        private String cloudId;
-        private String key;
-        private String value;
-
-        public ArbitraryDataSet(int id, String cloudId, String key, String value) {
-            this.id = id;
-            this.cloudId = cloudId;
-            this.key = key;
-            this.value = value;
-        }
-
-        public int getId() {
-            return id;
-        }
 
-        public String getCloudId() {
-            return cloudId;
-        }
-
-        public String getKey() {
-            return key;
-        }
-
-        public String getValue() {
-            return value;
-        }
-    }
 
 }

+ 43 - 0
src/main/java/com/owncloud/android/datamodel/ArbitraryDataSet.java

@@ -0,0 +1,43 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2020 Tobias Kaminsky
+ * Copyright (C) 2020 Nextcloud GmbH
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+package com.owncloud.android.datamodel;
+
+import lombok.Getter;
+
+/**
+ * Data set for {@link ArbitraryDataProvider}
+ */
+@Getter
+class ArbitraryDataSet {
+    private int id;
+    private String cloudId;
+    private String key;
+    private String value;
+
+    ArbitraryDataSet(int id, String cloudId, String key, String value) {
+        this.id = id;
+        this.cloudId = cloudId;
+        this.key = key;
+        this.value = value;
+    }
+}