public class

ModelUtil

extends Object
java.lang.Object
   ↳ fm.audiobox.core.utils.ModelUtil

Class Overview

Handful util class for various models tasks.

Summary

Constants
String AUDIOBOX_DATE_FORMAT
String ID_PLACEHOLDER
String TOKEN_PLACEHOLDER
Public Constructors
ModelUtil()
Public Methods
static Playlist findPlaylistByType(List<Playlist> playlists, String type)
Given the user's playlists and the desired type this method will return the right playlist.
static String interpolate(String url, long id)
Performs models urls interpolation with the ID_PLACEHOLDER.
static String interpolate(String url, String token)
Performs models urls interpolation with the TOKEN_PLACEHOLDER.
static long toUnixTime(SimpleDateFormat simpleDateFormat, String audioboxDate)
Given a string representing an UTC date provided by AudioBox server, this method returns a unix timestamp (always in UTC).
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String AUDIOBOX_DATE_FORMAT

Constant Value: "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

public static final String ID_PLACEHOLDER

Constant Value: ":id:"

public static final String TOKEN_PLACEHOLDER

Constant Value: ":token:"

Public Constructors

public ModelUtil ()

Public Methods

public static Playlist findPlaylistByType (List<Playlist> playlists, String type)

Given the user's playlists and the desired type this method will return the right playlist.
If the playlist is not found null is returned.

Parameters
playlists the user's playlists
type the Playlists#PLAYLIST_* type to find

public static String interpolate (String url, long id)

Performs models urls interpolation with the ID_PLACEHOLDER.

Parameters
url the url
id the id
Returns
  • the computed url interpolation

public static String interpolate (String url, String token)

Performs models urls interpolation with the TOKEN_PLACEHOLDER.

Parameters
url the url
token the token
Returns
  • the computed url interpolation

public static long toUnixTime (SimpleDateFormat simpleDateFormat, String audioboxDate)

Given a string representing an UTC date provided by AudioBox server, this method returns a unix timestamp (always in UTC).

Parameters
simpleDateFormat the simple date format
audioboxDate the string date provided by audiobox server.
Returns
  • unix timestamp
Throws
ParseException the parse exception