-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix-todo-checks
- Loading branch information
Showing
18 changed files
with
190 additions
and
81 deletions.
There are no files selected for viewing
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
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
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
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
13 changes: 13 additions & 0 deletions
13
utility/src/main/java/org/oppia/android/util/enumfilter/BUILD.bazel
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,13 @@ | ||
""" | ||
General purpose utility for filtering enums. | ||
""" | ||
|
||
load("@io_bazel_rules_kotlin//kotlin:android.bzl", "kt_android_library") | ||
|
||
kt_android_library( | ||
name = "enum_filter_util", | ||
srcs = [ | ||
"EnumFilterUtil.kt", | ||
], | ||
visibility = ["//:oppia_api_visibility"], | ||
) |
20 changes: 20 additions & 0 deletions
20
utility/src/main/java/org/oppia/android/util/enumfilter/EnumFilterUtil.kt
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,20 @@ | ||
package org.oppia.android.util.enumfilter | ||
|
||
/** | ||
* Filters a collection based on a condition applied to an enum property of each element. | ||
* | ||
* @param E the type of enum values. | ||
* @param T the type of elements in the collection. | ||
* @param collection the collection of elements to filter. | ||
* @param enumExtractor a function that extracts the enum value from each element. | ||
* @param condition a predicate function that determines if an enum value should be included in the result. | ||
* @return a list of elements from the collection that satisfy the condition when their enum property is evaluated. | ||
*/ | ||
|
||
inline fun <E : Enum<E>, T> filterByEnumCondition( | ||
collection: Collection<T>, | ||
enumExtractor: (T) -> E, | ||
condition: (E) -> Boolean | ||
): List<T> { | ||
return collection.filter { condition(enumExtractor(it)) } | ||
} |
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
Oops, something went wrong.