Como consecuencia esto llevo a modificar otras clases que la utilizaban ya que se decidieron cambiar un par de cosas en su API - Quitar el que los metodos de update e insert retornaran un booleano, realmente no era algo necesario y no se estaba utilizando. - Remplazar el retornar una Caja por retornar un Optional<Caja> en los metodos de getByFecha y getById, con el fin eliminar un poco los chequeos de nulls - El metodo de cajasFromResultSet fue eliminado ya que no lo veia necesario ya que operaba generaba una List con las cajas obtenidas por el ResultSet y los de los 2 metodos que la invocaban, solo uno de ellos necesitaba una lista, el otro solo obtenia el primero de la lista y continuaba. - Cambie el necesitar un LocalDate en el metodo que genera las cajas para un mes, por un objeto con logico para esta situacion, el cual es YearMonth, esto tuvo como consecuencia la mayoria de los cambios fuera de esta clase. - Renombre los metodos para que tuvieran nombres mas agradables para mi, esto es lo otro que hizo cambiar muchas otras clases.
48 lines
1.5 KiB
Java
48 lines
1.5 KiB
Java
/*
|
|
* MIT License
|
|
*
|
|
* Copyright (c) 2018-2019 Daniel Cortes
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
package danielcortes.xyz.models.caja;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.YearMonth;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
public interface CajaDAO {
|
|
List<Caja> getAll();
|
|
|
|
Optional<Caja> getById(int id);
|
|
|
|
Optional<Caja> getByFecha(LocalDate fecha);
|
|
|
|
void insert(Caja caja);
|
|
|
|
void insert(List<Caja> cajas);
|
|
|
|
void update(Caja caja);
|
|
|
|
void createCajasForMonth(YearMonth month);
|
|
|
|
}
|