Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make code cleaner #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public abstract class AbstractMapService<T extends BaseEntity, ID extends Long>

protected Map<Long, T> map = new HashMap<>();

Set<T> findAll(){
public Set<T> findAll(){
return new HashSet<>(map.values());
}

T findById(ID id) {
public T findById(ID id) {
return map.get(id);
}

T save(T object){
public T save(T object){

if(object != null) {
if(object.getId() == null){
Expand All @@ -34,11 +34,11 @@ T save(T object){
return object;
}

void deleteById(ID id){
public void deleteById(ID id){
map.remove(id);
}

void delete(T object){
public void delete(T object){
map.entrySet().removeIf(entry -> entry.getValue().equals(object));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ public OwnerMapService(PetTypeService petTypeService, PetService petService) {
this.petService = petService;
}

@Override
public Set<Owner> findAll() {
return super.findAll();
}

@Override
public Owner findById(Long id) {
return super.findById(id);
}

@Override
public Owner save(Owner object) {

Expand Down Expand Up @@ -64,16 +54,6 @@ public Owner save(Owner object) {
}
}

@Override
public void delete(Owner object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}

@Override
public Owner findByLastName(String lastName) {
return this.findAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,4 @@
@Service
@Profile({"default", "map"})
public class PetMapService extends AbstractMapService<Pet, Long> implements PetService {
@Override
public Set<Pet> findAll() {
return super.findAll();
}

@Override
public Pet findById(Long id) {
return super.findById(id);
}

@Override
public Pet save(Pet object) {
return super.save(object);
}

@Override
public void delete(Pet object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,4 @@
@Service
@Profile({"default", "map"})
public class PetTypeMapService extends AbstractMapService<PetType, Long> implements PetTypeService {

@Override
public Set<PetType> findAll() {
return super.findAll();
}

@Override
public PetType findById(Long id) {
return super.findById(id);
}

@Override
public PetType save(PetType object) {
return super.save(object);
}

@Override
public void delete(PetType object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,4 @@
@Service
@Profile({"default", "map"})
public class SpecialityMapService extends AbstractMapService<Speciality, Long> implements SpecialtyService {

@Override
public Set<Speciality> findAll() {
return super.findAll();
}

@Override
public Speciality findById(Long id) {
return super.findById(id);
}

@Override
public Speciality save(Speciality object) {
return super.save(object);
}

@Override
public void delete(Speciality object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ public VetMapService(SpecialtyService specialtyService) {
this.specialtyService = specialtyService;
}

@Override
public Set<Vet> findAll() {
return super.findAll();
}

@Override
public Vet findById(Long id) {
return super.findById(id);
}

@Override
public Vet save(Vet object) {

Expand All @@ -46,14 +36,4 @@ public Vet save(Vet object) {

return super.save(object);
}

@Override
public void delete(Vet object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
@Profile({"default", "map"})
public class VisitMapService extends AbstractMapService<Visit, Long> implements VisitService {

@Override
public Set<Visit> findAll() {
return super.findAll();
}

@Override
public Visit findById(Long id) {
return super.findById(id);
}

@Override
public Visit save(Visit visit) {

Expand All @@ -34,14 +24,4 @@ public Visit save(Visit visit) {

return super.save(visit);
}

@Override
public void delete(Visit object) {
super.delete(object);
}

@Override
public void deleteById(Long id) {
super.deleteById(id);
}
}