티스토리 뷰
1.Comparator
- Comparator.comparing : comparing은 Comparator의 정적 메서드로 Function을 인자로 받는다.
<예> Comparator<Test> c = Comparator.comparing(Test::getTest);
- reversed : 역정렬
<예> Comparator.comparing(Test::getTest).reversed();
- thenComparing : 첫 비교결과가 동일할 경우 다음 비교 Function을 설정할 수 있다.
<예> Comparator.comparing(Test::getTest).reversed().thenComparing(Test::getScore());
2. Predicate
- negate : 기존 Predicate을 반전 시킬때
<예> Predicate<Test> notMaxScore = maxScore.negate();
- and : Predicate들을 and 조건으로 연결하여 하나의 Predicate로 만들 때.
<예> Predicate<Test> maxAndMin = maxScore.and(Test::min);
- or : Predicate들을 or 조건으로 연결하여 하나의 Predicate로 만들 때.
<예> Predicate<Test> maxAndMinOrMath = maxScore.and(Test::min).or(Test::math);
3. Function
- andThen : 주어진 함수를 먼저 연산하고 연산한 결과를 다음 함수에 전달한다.
<예>
Function<Integer, Integer> f = x -> x + 4;
Function<Integer, Integer> g = x -> x * 4;
Function<Integer, Integer> h = f.andThen(g);
-> f를 먼저 연산하고 g를 연산
h.apply(1) -> 20
- compose : 인수로 주어진 함수를 먼저 연산하고 그 결과를 앞선 함수에 적용한다. Function<Integer, Integer> f = x -> x + 4;
Function<Integer, Integer> g = x -> x * 4;
Function<Integer, Integer> h = f.compose(g);
-> g를 먼저 연산하고 f를 연산
h.apply(1) -> 8
*참고 : Java 8 in Action (한빛 미디어)
'JAVA' 카테고리의 다른 글
자바 성능 튜닝 정보 알아보기! (0) | 2024.01.30 |
---|---|
JPA + Hibernate 설치 및 구성 알아보기! (0) | 2021.07.02 |
[JAVA8] Lambda(람다)에서 지역변수 사용하기 (0) | 2019.04.17 |
[JAVA8] 함수형 인터페이스 정리 (0) | 2019.04.15 |
[JAVA] OkHttp로 REST API 호출하기 (0) | 2019.01.18 |
- Total
- Today
- Yesterday
- tensorflow
- 데이터파이프라인
- it
- okhttp
- 딥러닝
- 소프트웨어
- HttpClient
- Java
- HTTP
- 데이터플랫폼설계
- Rest
- 인공지능
- llm
- 프로그램
- ai
- java8
- Spring
- 교육
- 자바
- 데이터플랫폼
- http client
- mlops
- API
- SW
- 머신러닝
- 빅데이터
- 소프트웨어교육
- AWS
- rest api
- 텐서플로우
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |