-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(java): browse objects/synonyms/rules (#952)
- Loading branch information
Showing
7 changed files
with
421 additions
and
248 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ient-java-2/algoliasearch-core/src/main/java/com/algolia/utils/AlgoliaIterableHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.algolia.utils; | ||
|
||
import java.util.Iterator; | ||
import java.util.function.BooleanSupplier; | ||
import java.util.function.Supplier; | ||
|
||
public class AlgoliaIterableHelper { | ||
|
||
public static <T> Iterable<T> createIterable(Supplier<Iterator<T>> executeQuery, BooleanSupplier _hasNext) { | ||
return new Iterable<T>() { | ||
@Override | ||
public Iterator<T> iterator() { | ||
return new Iterator<T>() { | ||
private boolean isFirstRequest = true; | ||
private Iterator<T> currentIterator = null; | ||
|
||
@Override | ||
public boolean hasNext() { | ||
if (isFirstRequest || (_hasNext.getAsBoolean() && !currentIterator.hasNext())) { | ||
currentIterator = executeQuery.get(); | ||
isFirstRequest = false; | ||
} | ||
return currentIterator != null && currentIterator.hasNext(); | ||
} | ||
|
||
@Override | ||
public T next() { | ||
if (currentIterator == null || !currentIterator.hasNext()) { | ||
currentIterator = executeQuery.get(); | ||
isFirstRequest = false; | ||
} | ||
return currentIterator.next(); | ||
} | ||
}; | ||
} | ||
}; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...lgoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/Holder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.algolia.utils; | ||
|
||
public class Holder<T> { | ||
|
||
public T value; | ||
|
||
public Holder() { | ||
this.value = null; | ||
} | ||
|
||
public Holder(T value) { | ||
this.value = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.