Skip to content

Commit 5b5c5a2

Browse files
committed
Chapter 11 code
1 parent e135931 commit 5b5c5a2

File tree

430 files changed

+99222
-7979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

430 files changed

+99222
-7979
lines changed

.metadata/.log

Lines changed: 885 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
*
3+
*/
4+
package com.packt.patterninspring.chapter11.reactivewebapp.repository;
5+
6+
import java.util.Map;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
9+
import com.packt.patterninspring.chapter11.reactivewebapp.model.Account;
10+
11+
import reactor.core.publisher.Flux;
12+
import reactor.core.publisher.Mono;
13+
14+
/**
15+
* @author Dinesh.Rajput
16+
*
17+
*/
18+
public class AccountRepositoryImpl implements AccountRepository {
19+
20+
private final Map<Long, Account> accountMap = new ConcurrentHashMap<>();
21+
22+
public AccountRepositoryImpl() {
23+
this.accountMap.put(1000l, new Account(1000l, "Dinesh Rajput", 50000l, "Sector-1"));
24+
this.accountMap.put(2000l, new Account(2000l, "Anamika Rajput", 60000l, "Sector-2"));
25+
this.accountMap.put(3000l, new Account(3000l, "Arnav Rajput", 70000l, "Sector-3"));
26+
this.accountMap.put(4000l, new Account(4000l, "Adesh Rajput", 80000l, "Sector-4"));
27+
}
28+
29+
@Override
30+
public Mono<Account> findById(Long id) {
31+
return Mono.justOrEmpty(this.accountMap.get(id));
32+
}
33+
34+
@Override
35+
public Flux<Account> findAll() {
36+
return Flux.fromIterable(this.accountMap.values());
37+
}
38+
39+
@Override
40+
public Mono<Void> save(Mono<Account> account) {
41+
Mono<Account> accountMono = account.doOnNext(account -> {
42+
accountMap.put(account.getId(), account);
43+
System.out.format("Saved %s with id %d%n", account, account.getId());
44+
});
45+
return accountMono.thenEmpty(Mono.empty());
46+
}
47+
48+
}

.metadata/.plugins/org.eclipse.core.resources/.history/10/b03b610c388a00171e30acfba4717df9

Lines changed: 0 additions & 35 deletions
This file was deleted.

.metadata/.plugins/org.eclipse.core.resources/.history/12/e06732b2648a00171e30acfba4717df9

Lines changed: 0 additions & 21 deletions
This file was deleted.

.metadata/.plugins/org.eclipse.core.resources/.history/13/304e37d1328a00171e30acfba4717df9

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
*
3+
*/
4+
package com.packt.patterninspring.chapter11.reactivewebapp.repository;
5+
6+
import java.util.Map;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
9+
import com.packt.patterninspring.chapter11.reactivewebapp.model.Account;
10+
11+
import reactor.core.publisher.Flux;
12+
import reactor.core.publisher.Mono;
13+
14+
/**
15+
* @author Dinesh.Rajput
16+
*
17+
*/
18+
public class AccountRepositoryImpl implements AccountRepository {
19+
20+
private final Map<Long, Account> accountMap = new ConcurrentHashMap<>();
21+
22+
public AccountRepositoryImpl() {
23+
this.accountMap.put(1000l, new Account(1000l, "Dinesh Rajput", 50000l, "Sector-1"));
24+
this.accountMap.put(2000l, new Account(2000l, "Anamika Rajput", 60000l, "Sector-2"));
25+
this.accountMap.put(3000l, new Account(3000l, "Arnav Rajput", 70000l, "Sector-3"));
26+
this.accountMap.put(4000l, new Account(4000l, "Adesh Rajput", 80000l, "Sector-4"));
27+
}
28+
29+
@Override
30+
public Mono<Account> findById(Long id) {
31+
return Mono.justOrEmpty(this.accountMap.get(id));
32+
}
33+
34+
@Override
35+
public Flux<Account> findAll() {
36+
return Flux.fromIterable(this.accountMap.values());
37+
}
38+
39+
@Override
40+
public Mono<Void> save(Mono<Account> account) {
41+
Mono<Account> accountMono = accountMap.doOnNext(account -> {
42+
accountMap.put(account.getId(), account);
43+
System.out.format("Saved %s with id %d%n", account, account.getId());
44+
});
45+
return accountMono.thenEmpty(Mono.empty());
46+
}
47+
48+
}

.metadata/.plugins/org.eclipse.core.resources/.history/17/701131c5558a00171e30acfba4717df9

Lines changed: 0 additions & 52 deletions
This file was deleted.

.metadata/.plugins/org.eclipse.core.resources/.history/1a/a0c66a78878600171214edd9a79d718e

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
*
3+
*/
4+
package com.packt.patterninspring.chapter11.reactivewebapp.repository;
5+
6+
import java.util.Map;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
9+
import com.packt.patterninspring.chapter11.reactivewebapp.model.Account;
10+
11+
import reactor.core.publisher.Flux;
12+
import reactor.core.publisher.Mono;
13+
14+
/**
15+
* @author Dinesh.Rajput
16+
*
17+
*/
18+
public class AccountRepositoryImpl implements AccountRepository {
19+
20+
private final Map<Long, Account> accountMap = new ConcurrentHashMap<>();
21+
22+
public AccountRepositoryImpl() {
23+
this.accountMap.put(1000l, new Account(1000l, "Dinesh Rajput", 50000l, "Sector-1"));
24+
this.accountMap.put(2000l, new Account(2000l, "Anamika Rajput", 60000l, "Sector-2"));
25+
this.accountMap.put(3000l, new Account(3000l, "Arnav Rajput", 70000l, "Sector-3"));
26+
this.accountMap.put(4000l, new Account(4000l, "Adesh Rajput", 80000l, "Sector-4"));
27+
}
28+
29+
@Override
30+
public Mono<Account> findById(Long id) {
31+
return Mono.justOrEmpty(this.accountMap.get(id));
32+
}
33+
34+
@Override
35+
public Flux<Account> findAll() {
36+
return Flux.fromIterable(this.accountMap.values());
37+
}
38+
39+
@Override
40+
public Mono<Account> save(Mono<Account> account) {
41+
return null;
42+
}
43+
44+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
*
3+
*/
4+
package com.packt.patterninspring.chapter11.reactivewebapp.repository;
5+
6+
import java.util.Map;
7+
import java.util.concurrent.ConcurrentHashMap;
8+
9+
import com.packt.patterninspring.chapter11.reactivewebapp.model.Account;
10+
11+
import reactor.core.publisher.Flux;
12+
import reactor.core.publisher.Mono;
13+
14+
/**
15+
* @author Dinesh.Rajput
16+
*
17+
*/
18+
public class AccountRepositoryImpl implements AccountRepository {
19+
20+
private final Map<Integer, Account> accountMap = new ConcurrentHashMap<>();
21+
22+
public AccountRepositoryImpl() {
23+
this.accountMap.put(1000, new Account(1000l, "Dinesh Rajput", 50000l, "Noida"));
24+
25+
this.accountMap.put(2000, new Account(512,
26+
"Spring Guru Mug",
27+
"Spring Framework Guru Green Cofee Mug",
28+
"https://springframework.guru/wp-content/uploads/2015/04/spring_framework_guru_coffee_mug-r11e7694903c348e1a667dfd2f1474d95_x7j54_8byvr_512.jpg",
29+
new BigDecimal("11.95")));
30+
}
31+
32+
@Override
33+
public Mono<Account> findById(Long id) {
34+
return null;
35+
}
36+
37+
@Override
38+
public Flux<Account> findAll() {
39+
return null;
40+
}
41+
42+
@Override
43+
public Mono<Account> save(Mono<Account> account) {
44+
return null;
45+
}
46+
47+
}

0 commit comments

Comments
 (0)