Skip to content

Commit

Permalink
Added Specific Getters
Browse files Browse the repository at this point in the history
  • Loading branch information
sumimakito committed Sep 26, 2015
1 parent 033a11a commit 1e8ce35
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
import net.minidev.json.JSONObject;
import net.minidev.json.JSONValue;

import org.json.JSONArray;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class KeyValueDatabase extends QKVDB implements QKVDBImpl {
public class KeyValueDatabase extends QKVDB implements QKVDBImpl,SpecificGettersImpl {
private HashMap<Object, Object> dMap;

public KeyValueDatabase(QuickKV quickKV, Context context) {
Expand Down Expand Up @@ -336,6 +338,46 @@ private boolean parseKVJS(JSONObject json) {
}
}

@Override
public <K> String getString(K k) {
return (String) get(k);
}

@Override
public <K> long getLong(K k) {
return (long) get(k);
}

@Override
public <K> int getInt(K k) {
return (int) get(k);
}

@Override
public <K> double getDouble(K k) {
return (double) get(k);
}

@Override
public <K> float getFloat(K k) {
return (float) get(k);
}

@Override
public <K> boolean getBoolean(K k) {
return (boolean) get(k);
}

@Override
public <K> org.json.JSONObject getJSONObject(K k) {
return (org.json.JSONObject) get(k);
}

@Override
public <K> org.json.JSONArray getJSONArray(K k) {
return (org.json.JSONArray) get(k);
}

public interface Callback {
public void onSuccess();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package com.github.sumimakito.quickkv.database;/*
*/
package com.github.sumimakito.quickkv.database;

public interface SpecificGettersImpl {
<K> String getString(K k);
<K> long getLong(K k);
<K> int getInt(K k);
<K> double getDouble(K k);
<K> float getFloat(K k);
<K> boolean getBoolean(K k);
<K> org.json.JSONObject getJSONObject(K k);
<K> org.json.JSONArray getJSONArray(K k);
}

0 comments on commit 1e8ce35

Please sign in to comment.