Merge pull request #7222 from amit2103/BAEL-14274-23
[BAEL-14274] - Fixed article code for https://www.baeldung.com/intro-…
This commit is contained in:
commit
ca022021b4
|
@ -13,9 +13,9 @@ public class GetterLazy {
|
|||
private static final String DELIMETER = ",";
|
||||
|
||||
@Getter(lazy = true)
|
||||
private final Map<String, Long> transactions = readTxnsFromFile();
|
||||
private final Map<String, Long> transactions = getTransactions();
|
||||
|
||||
private Map<String, Long> readTxnsFromFile() {
|
||||
private Map<String, Long> getTransactions() {
|
||||
|
||||
final Map<String, Long> cache = new HashMap<>();
|
||||
List<String> txnRows = readTxnListFromFile();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.lombok.intro;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.Synchronized;
|
||||
|
||||
public class Utility {
|
||||
|
||||
@SneakyThrows
|
||||
public String resourceAsString() throws IOException {
|
||||
try (InputStream is = this.getClass().getResourceAsStream("sure_in_my_jar.txt")) {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
public void putValueInCache(String key, String value) {
|
||||
System.out.println("Thread safe here with key : [" + key + "] and value[" + value + "]");
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Hello
|
Loading…
Reference in New Issue