Predicate

· Java
자바 8 라이브러리 설계자들은 java.util.function 패키지로 여러가지 새로운 함수형 인터페이스를 제공한다. Predicate java.util.function.Predicate 인터페이스는 test라는 추상 메서드를 정의하며 test는 제네릭 형식 T의 객체를 인수로 받아 boolean을 반환한다. T 형식의 객체를 사용하는 boolean 표현식이 필요한 상황에서 Predicate 인터페이스를 사용할 수 있다. @FunctionalInterface public interface Predicate { boolean test(T t); } public List filter(List list, Predicate P) { List results = new ArrayList(); for (T t:li..
· JPA
Spring Data JPA는 org.springframework.data.jpa.domain.Specification 클래스로 다양한 검색조건을을 조립해서 새로운 검색조건을 만들 수 있다. 본래에 JpaRepository 상속받을때 JpaSpecificationExecutor을 상속받으면 된다. public interface JpaSpecificationExecutor { T findOn(Specification spec); List findAll(Specification spec); Page findAll(Specification spec, Pageable pagaable); List findAll(Specification spec, Sort sort); long count(Specification ..
beekei
'Predicate' 태그의 글 목록