-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add utility functions for base model classes
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/info/movito/themoviedbapi/util/ModelUtil.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,37 @@ | ||
package info.movito.themoviedbapi.util; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import info.movito.themoviedbapi.model.core.NamedIdElement; | ||
import info.movito.themoviedbapi.model.core.NamedStringIdElement; | ||
|
||
/** | ||
* TMDB API Model Utility. | ||
*/ | ||
public final class ModelUtil { | ||
private ModelUtil() { | ||
} | ||
|
||
/** | ||
* Gets a list of names (from the name field) from the items in the collection provided. | ||
* For model classes extending {@link NamedIdElement}. | ||
* | ||
* @param collection the collection. | ||
* @return the list of names. | ||
*/ | ||
public static List<String> getNames(Collection<? extends NamedIdElement> collection) { | ||
return collection.stream().map(NamedIdElement::getName).toList(); | ||
} | ||
|
||
/** | ||
* Gets a list of names (from the name field) from the items in the collection provided. | ||
* For model classes extending {@link NamedStringIdElement}. | ||
* | ||
* @param collection the collection. | ||
* @return the list of names. | ||
*/ | ||
public static List<String> getNamesString(Collection<? extends NamedStringIdElement> collection) { | ||
return collection.stream().map(NamedStringIdElement::getName).toList(); | ||
} | ||
} |
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