-
Notifications
You must be signed in to change notification settings - Fork 2
/
SOLID_O.java
78 lines (62 loc) · 1.42 KB
/
SOLID_O.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import java.util.List;
import java.util.stream.*;
import java.io.*;
// Setting Value to Enumurable.
enum Color
{
RED, GREEN, BLUE, YELLOW, BLACK, WHITE, PINK, VIOLET, BROWN, GRAY, ORANGE
}
enum Size
{
VERYSMALL, SMALL, MEDIUM, LARGE, VERYLARGE, EXTRA
}
enum Category
{
FOOD, ENTERTAINMENT, BOOK, ACCESSORY, CLOTHING, CONSUMING, STATIONARY, GADGET, OTHER
}
// Create Product Initialization Class.
class Product
{
public String name;
public Color color;
public Size size;
public Category category;
public Product(String name, Color color, Size size, Category category)
{
this.name = name;
this.color = color;
this.size = size;
this.category = category;
}
}
class ProductFilter
{
}
interface Filter<T>
{
Stream<T> filter(List<T> item, Specification<T> spec);
}
class GreatFilter implements Filter<Product>
{
@Override
public Stream<Product> filter(List<Product> item, Specification<Product> spec)
{
return;
}
}
interface Specification<T>
{
}
class ColorSpecification implements Specification<Product>
{
}
public class SOLID_O
{
public static void main(String[] args)
{
Product banana = new Product("Banana", Color.GREEN, Size.MEDIUM, Category.FOOD);
Product pencil01 = new Product("Rotting", Color.BLACK, Size.SMALL, Category.STATIONARY);
Product smartphone01 = new Product("iPhone 20", Color.GRAY, Size.SMALL, Category.GADGET);
List<Product> products = List.of(banana, pencil01, smartphone01);
}
}