Skip to content

Commit

Permalink
Merge pull request #11 from playmoweb/support-id
Browse files Browse the repository at this point in the history
Id supports now String or Integer
  • Loading branch information
tspoke authored May 9, 2018
2 parents c5803e4 + cf3b3ab commit 086bdd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ public Flowable<Optional<List<T>>> getAll(List<T> items) {

if(items.size() > 0){
String paramName = items.get(0).getUniqueIdentifierName();
Integer[] keys = new Integer[items.size()];
Object[] keys = new Object[items.size()];
for(int i = 0; i < items.size(); i++){
keys[i] = items.get(i).getUniqueIdentifier();
}
query.in(paramName, keys);

Object valueType = items.get(0).getUniqueIdentifier();
if(valueType instanceof String){
query.in(paramName, (String[]) keys);
} else if(valueType instanceof Integer){
query.in(paramName, (Integer[]) keys);
}
}

List<T> copies = realm.copyFromRealm(query.findAll());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Created by thibaud on 13/09/2017.
*/
public interface HasId {
int getUniqueIdentifier();
public interface HasId<T> {
T getUniqueIdentifier();
String getUniqueIdentifierName();
}

0 comments on commit 086bdd5

Please sign in to comment.