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:
Loredana Crusoveanu 2019-07-20 21:54:59 +03:00 committed by GitHub
commit ca022021b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -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();

View File

@ -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 + "]");
}
}

View File

@ -0,0 +1 @@
Hello