Skip to content

Commit

Permalink
Id suppors now String or Integer
Browse files Browse the repository at this point in the history
  • Loading branch information
tspoke committed May 7, 2018
1 parent c5803e4 commit cf3b3ab
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 cf3b3ab

Please sign in to comment.