Class ScaleRepository
- java.lang.Object
-
- edu.cnm.deepdive.scalescroller.service.ScaleRepository
-
-
Constructor Summary
Constructors Constructor Description ScaleRepository(Context context)
The constructor initializes the context, the database, and the dao.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
delete(Scale scale)
Deletes a scale record in the database.LiveData<Scale>
get(long id)
Returns LiveData of a scale, given its id.LiveData<List<Scale>>
getAll()
Returns LiveData of all scales.LiveData<List<Scale>>
getAllOrdered()
Returns LiveData of all scales, ordered by difficulty.LiveData<List<Scale>>
getByMode(Mode mode)
Returns LiveData of all scales with the specified mode.LiveData<Scale>
getByScaleName(Mode mode, Note tonic)
Returns LiveData of a scale, given its tonic and mode.LiveData<List<Scale>>
getByTonic(Note tonic)
Returns LiveData of all scales with the specified tonic.Completable
save(Scale scale)
Creates or updates a scale record in the database.
-
-
-
Constructor Detail
-
ScaleRepository
public ScaleRepository(Context context)
The constructor initializes the context, the database, and the dao.- Parameters:
context
- The application context.
-
-
Method Detail
-
save
public Completable save(Scale scale)
Creates or updates a scale record in the database.- Parameters:
scale
- TheScale
.- Returns:
- A
Completable
indicating the success or failure of the creation/update.
-
delete
public Completable delete(Scale scale)
Deletes a scale record in the database.- Parameters:
scale
- TheScale
.- Returns:
- A
Completable
indicating the success or failure of the deletion.
-
get
public LiveData<Scale> get(long id)
Returns LiveData of a scale, given its id.- Parameters:
id
- The id of the scale.- Returns:
LiveData
of aScale
.
-
getAll
public LiveData<List<Scale>> getAll()
Returns LiveData of all scales.- Returns:
LiveData
of aList
ofScale
.
-
getAllOrdered
public LiveData<List<Scale>> getAllOrdered()
Returns LiveData of all scales, ordered by difficulty.- Returns:
LiveData
of aList
ofScale
.
-
getByScaleName
public LiveData<Scale> getByScaleName(Mode mode, Note tonic)
Returns LiveData of a scale, given its tonic and mode.- Parameters:
mode
- The mode of the scale.tonic
- The tonic of the scale.- Returns:
LiveData
of aScale
.
-
getByTonic
public LiveData<List<Scale>> getByTonic(Note tonic)
Returns LiveData of all scales with the specified tonic.- Parameters:
tonic
- The tonic of the scale.- Returns:
LiveData
of aList
ofScale
.
-
-