-
Notifications
You must be signed in to change notification settings - Fork 70
/
ConsultantStubImpl.java
60 lines (48 loc) · 1.61 KB
/
ConsultantStubImpl.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
package com.levent.consultantapi.repository.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.levent.consultantapi.model.Consultant;
import com.levent.consultantapi.repository.ConsultantRepository;
@Repository
public class ConsultantStubImpl implements ConsultantRepository {
private Map<Long, Consultant> consultants;
private Long idIndex;
public ConsultantStubImpl() {
// init
consultants = new HashMap<Long, Consultant>();
idIndex = 5L;
// populate consultants
Consultant a = new Consultant(1L, "Levent", "Divilioglu", 36, false, null);
consultants.put(1L, a);
Consultant b = new Consultant(2L, "Hakan", "Yorukoglu", 41, true, "Kut-Tech");
consultants.put(2L, b);
Consultant c = new Consultant(3L, "Goktug", "Temur", 32, true, "Alfa-5");
consultants.put(3L, c);
Consultant d = new Consultant(4L, "Altug", "Dogan", 27, false, null);
consultants.put(4L, d);
Consultant e = new Consultant(5L, "Atilla", "Tanridagi", 29, true, "Kafkas-Tech");
consultants.put(5L, e);
}
public List<Consultant> list() {
return new ArrayList<Consultant>(consultants.values());
}
public Consultant create(Consultant consultant) {
idIndex += idIndex;
consultant.setId(idIndex);
consultants.put(idIndex, consultant);
return consultant;
}
public Consultant get(Long id) {
return consultants.get(id);
}
public Consultant update(Long id, Consultant consultant) {
consultants.put(id, consultant);
return consultant;
}
public Consultant delete(Long id) {
return consultants.remove(id);
}
}