Package com.tagtraum.beatunes.inspection
Class CallableSolution
- java.lang.Object
-
- com.tagtraum.beatunes.inspection.CallableSolution
-
public abstract class CallableSolution extends Object implements Callable<Void>
Code that should be executed, when aSolution
is actually applied/commited.- Author:
- Hendrik Schreiber
- See Also:
Solution.createCallable(java.util.Collection, boolean)
-
-
Field Summary
Fields Modifier and Type Field Description protected PropertyChangeSupport
propertyChangeSupport
-
Constructor Summary
Constructors Modifier Constructor Description protected
CallableSolution(Solution solution, String description, String progressMessage)
Steps is set to -1, i.e.protected
CallableSolution(Solution solution, Collection<AudioSong> songs, String description, String progressMessage, int steps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(CallableSolution otherCallableSolution)
Adds another solution to this one, basically combining them.void
addProgressListener(ProgressListener progressListener)
void
addPropertyChangeListener(PropertyChangeListener listener)
void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
boolean
canAdd(CallableSolution otherCallableSolution)
Offers a way to check whether you can combine two tasks into one (this).void
fireProgress(float progress)
Fires progress for visual indicator.Throwable
getCommitError()
Non-null, if a commitment attempt was unsuccessful.String
getDescription()
Static description of the solution.String
getProgressMessage()
Message that can be shown while the solution is executed.Solution
getSolution()
List<Long>
getSongIds()
Ids of the songs that are going to be modified by this solution.int
getSteps()
Approximate number of distinct steps in this solution.protected List<Track>
getTracks(BeaTunes application, Collection<Long> songIds)
Retrieves a list ofTrack
objects from the music player.void
setCommitError(Throwable commitError)
protected void
setDescription(String description)
protected void
setProgressMessage(String progressMessage)
protected void
setSolution(Solution solution)
void
setSongIds(Collection<Long> songIds)
Sets the ids of the songs that are going to be modified by this solution.void
setSongs(Collection<AudioSong> songs)
Extracts the ids from the given songs and sets them usingsetSongIds(java.util.Collection)
.protected void
setSteps(int steps)
int
songCount()
Number of songs affected by this solution.String
toString()
-
-
-
Field Detail
-
propertyChangeSupport
protected final PropertyChangeSupport propertyChangeSupport
-
-
Constructor Detail
-
CallableSolution
protected CallableSolution(Solution solution, String description, String progressMessage)
Steps is set to -1, i.e. it will be computed fromsongCount()
.- Parameters:
solution
- actual solution this belongs todescription
- static description of the solutionprogressMessage
- message that may be shown while the solution is applied.
-
CallableSolution
protected CallableSolution(Solution solution, Collection<AudioSong> songs, String description, String progressMessage, int steps)
- Parameters:
solution
- actual solution this belongs tosongs
- songs, most likely selected by the user, seeSolution.createCallable(Collection, boolean)
description
- static description of the solutionprogressMessage
- message that may be shown while the solution is applied.steps
- number of steps it will take in total - this will be available throughgetSteps()
. If set to -1, it will be computed automatically fromsongCount()
.
-
-
Method Detail
-
getCommitError
public Throwable getCommitError()
Non-null, if a commitment attempt was unsuccessful.- Returns:
- commit error
-
setCommitError
public void setCommitError(Throwable commitError)
-
getSolution
public Solution getSolution()
-
setSolution
protected void setSolution(Solution solution)
-
getProgressMessage
public String getProgressMessage()
Message that can be shown while the solution is executed.- Returns:
- progress message
-
setProgressMessage
protected void setProgressMessage(String progressMessage)
-
getDescription
public String getDescription()
Static description of the solution.- Returns:
- description
-
setDescription
protected void setDescription(String description)
-
getSteps
public int getSteps()
Approximate number of distinct steps in this solution.- Returns:
- steps
-
setSteps
protected void setSteps(int steps)
-
getSongIds
public List<Long> getSongIds()
Ids of the songs that are going to be modified by this solution.- Returns:
- list of song ids or empty list
- See Also:
setSongIds(Collection)
-
setSongIds
public void setSongIds(Collection<Long> songIds)
Sets the ids of the songs that are going to be modified by this solution.- Parameters:
songIds
- list of song ids- See Also:
getSongIds()
,setSongs(Collection)
-
setSongs
public void setSongs(Collection<AudioSong> songs)
Extracts the ids from the given songs and sets them usingsetSongIds(java.util.Collection)
.- Parameters:
songs
- songs- See Also:
setSongIds(Collection)
-
songCount
public int songCount()
Number of songs affected by this solution.- Returns:
- song count
-
canAdd
public boolean canAdd(CallableSolution otherCallableSolution)
Offers a way to check whether you can combine two tasks into one (this).- Parameters:
otherCallableSolution
- another asynchronous solution- Returns:
- true, if the given task can be added to this task.
-
add
public void add(CallableSolution otherCallableSolution)
Adds another solution to this one, basically combining them.- Parameters:
otherCallableSolution
- another asynchronous solution- Throws:
IllegalArgumentException
- if the solution cannot be added.
-
addProgressListener
public void addProgressListener(ProgressListener progressListener)
-
fireProgress
public void fireProgress(float progress)
Fires progress for visual indicator.- Parameters:
progress
- percent done between 0.0f and 1.0f
-
getTracks
protected List<Track> getTracks(BeaTunes application, Collection<Long> songIds)
Retrieves a list of
Track
objects from the music player. While doing so callsfireProgress(float)
withi/
getSteps()
,i
being the number of the track in question.Must be called from
TunesUtilities
thread.- Parameters:
application
- applicationsongIds
- collection of songs ids- Returns:
- list of tracks
- See Also:
TunesUtilities.getTrack(Playlist, Long)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
-