-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.java
More file actions
36 lines (24 loc) · 844 Bytes
/
App.java
File metadata and controls
36 lines (24 loc) · 844 Bytes
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
32
33
34
35
36
package kr.springboot.examples.ex23;
import kr.springboot.examples.commons.User;
import java.util.Optional;
/**
* Reject Wrapped Values Based on a Predefined Rule Using filter()
* filter()를 사용하여 미리 정의된 규칙에 따라 래핑된 값 거부하기
*/
public class App {
// Avoid
public boolean validatePasswordLengthAvoidExample(User userId) {
Optional<String> password = Optional.of("MR.LEE***"); // User password
if (password.isPresent()) {
return password.get().length() > 5;
}
return false;
}
// Prefer
public boolean validatePasswordLengthPreferExample() {
Optional<String> password = Optional.of("IM A GOD****"); // GOD IS ME
return password
.filter(p -> p.length() > 5)
.isPresent();
}
}