Package com.tagtraum.audiokern
Interface AudioGenre
-
public interface AudioGenre
Genre.- Author:
- Hendrik Schreiber
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static List<AudioGenre>
findPath(AudioGenre genre1, AudioGenre genre2)
Find a short path from one genre to another.default List<AudioGenre>
findPathTo(AudioGenre genre)
Find a short path from this genre to another.String
getDescription()
String
getDescription(Locale locale)
Set<AudioId>
getIds()
Ids for this genre.default int
getLevel()
Level is defined as the length of the shortest path to a genre without parents navigating only the parent link.String
getName()
Default name.String
getName(Locale locale)
Attempts to return a genre name suitable for the given locale taking both language and country into account.Set<AudioGenre>
getParents()
Set of parents.default boolean
isRoot()
Does this genre have parents or is it a root genre?default List<List<AudioGenre>>
pathsToRoot()
static List<List<AudioGenre>>
pathsToRoot(AudioGenre genre, List<AudioGenre> pathToGenre)
Returns all possible paths to a root (genre without parent) usinggetParents()
.
-
-
-
Method Detail
-
getDescription
String getDescription()
-
getName
String getName()
Default name.- Returns:
- name
-
getName
String getName(Locale locale)
Attempts to return a genre name suitable for the given locale taking both language and country into account. If a country match fails, just the language is used. If that fails too,null
is returned.- Parameters:
locale
- locale- Returns:
- localized genre name, if at all possible
-
getParents
Set<AudioGenre> getParents()
Set of parents. Fusion genres typically have more than one parent.- Returns:
- parent set
-
getLevel
default int getLevel()
Level is defined as the length of the shortest path to a genre without parents navigating only the parent link. A genre without parents always has the level
0
. A genre with parents, but no grand-parents has level1
, and so on.The default implementation is not efficient.
- Returns:
- length of shortest path to a root genre
-
isRoot
default boolean isRoot()
Does this genre have parents or is it a root genre?
- Returns:
- true or false
-
findPathTo
default List<AudioGenre> findPathTo(AudioGenre genre)
Find a short path from this genre to another. If no path is found, an empty path is returned. If the two genres are identical, a path with just one element is returned.- Parameters:
genre
- other genre- Returns:
- a path or an empty list
-
findPath
static List<AudioGenre> findPath(AudioGenre genre1, AudioGenre genre2)
Find a short path from one genre to another. If no path is found, an empty path is returned. If the two genres are identical, a path with just one element is returned.- Parameters:
genre1
- genre 1genre2
- genre 2- Returns:
- a path from genre1 to genre2.
-
pathsToRoot
default List<List<AudioGenre>> pathsToRoot() throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
pathsToRoot
static List<List<AudioGenre>> pathsToRoot(AudioGenre genre, List<AudioGenre> pathToGenre)
Returns all possible paths to a root (genre without parent) usinggetParents()
. The paths contain the root genre and the genre we started from. The returned paths are orders, beginning with the shortest possible path.- Parameters:
genre
- genre- Returns:
- possible paths to root
-
-