Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Created November 26, 2019 07:59
Show Gist options
  • Save hongbeomi/c9d35aa7e49c9c8b880ee8e586a0fcea to your computer and use it in GitHub Desktop.
Save hongbeomi/c9d35aa7e49c9c8b880ee8e586a0fcea to your computer and use it in GitHub Desktop.
// 선택 조건을 결정하는 인터페이스 정의
public interface ApplePredicate{
boolean test (Apple apple);
}
// 무거운 사과만 선택
public class AppleHeavyWeightPredicate implements ApplePredicate {
public boolean test(Apple apple) {
return apple.getWeight() > 150;
}
}
// 녹색 사과만 선택
public class AppleGreenColorPredicate implements ApplePredicate {
public boolean test(Apple apple) {
return GREEN.equals(apple.getColor());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment