Skip to content

Commit

Permalink
feat: AbstractMemoryRepository 메서드 추가
Browse files Browse the repository at this point in the history
- existsById, deleteById, count
  • Loading branch information
seokjin8678 committed Apr 8, 2024
1 parent 1824ebc commit e5ca18a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

public class MemoryArtistRepository extends AbstractMemoryRepository<Artist> implements ArtistRepository {

@Override
public void deleteById(Long artistId) {
memory.remove(artistId);
}

@Override
public long countByIdIn(List<Long> artistIds) {
return memory.values().stream()
Expand All @@ -25,9 +20,4 @@ public List<Artist> findByIdIn(Collection<Long> artistIds) {
.filter(artist -> artistIds.contains(artist.getId()))
.toList();
}

@Override
public boolean existsById(Long id) {
return memory.containsKey(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

public class MemoryBookmarkRepository extends AbstractMemoryRepository<Bookmark> implements BookmarkRepository {

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

@Override
public boolean existsByBookmarkTypeAndMemberIdAndResourceId(
BookmarkType bookmarkType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,4 @@ public boolean existsBySchoolId(Long schoolId) {
return memory.values().stream()
.anyMatch(festival -> Objects.equals(festival.getSchool().getId(), schoolId));
}

@Override
public void deleteById(Long festivalId) {
memory.remove(festivalId);
}

@Override
public boolean existsById(Long festivalId) {
return memory.containsKey(festivalId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ public void delete(Member member) {
memory.remove(member.getId());
}

@Override
public boolean existsById(Long id) {
return memory.containsKey(id);
}

@Override
public long count() {
return memory.size();
}

@Override
public Optional<Member> findBySocialIdAndSocialType(String socialId, SocialType socialType) {
return memory.values().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@

public class MemorySchoolRepository extends AbstractMemoryRepository<School> implements SchoolRepository {

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

@Override
public boolean existsById(Long id) {
return memory.get(id) != null;
}

@Override
public boolean existsByDomain(String domain) {
return memory.values().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

public class MemoryStageRepository extends AbstractMemoryRepository<Stage> implements StageRepository {

@Override
public void deleteById(Long stageId) {
memory.remove(stageId);
}

@Override
public void flush() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ final public T save(T entity) {
final public Optional<T> findById(Long id) {
return Optional.ofNullable(memory.get(id));
}

final public boolean existsById(Long id) {
return memory.containsKey(id);
}

final public void deleteById(Long id) {
memory.remove(id);
}

final public long count() {
return memory.size();
}
}

0 comments on commit e5ca18a

Please sign in to comment.