Skip to content

Commit 44bf480

Browse files
author
eugenp
committed
formatting work
1 parent 1eb53d5 commit 44bf480

File tree

44 files changed

+341
-484
lines changed

Some content is hidden

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

44 files changed

+341
-484
lines changed

apache-cxf/cxf-introduction/src/main/java/com/baeldung/cxf/introduction/Server.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void main(String args[]) throws InterruptedException {
88
String address = "http://localhost:8080/baeldung";
99
Endpoint.publish(address, implementor);
1010
System.out.println("Server ready...");
11-
Thread.sleep(60 * 1000);
11+
Thread.sleep(60 * 1000);
1212
System.out.println("Server exiting");
1313
System.exit(0);
1414
}

apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/RestfulServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void main(String args[]) throws Exception {
1111
factoryBean.setResourceProvider(new SingletonResourceProvider(new CourseRepository()));
1212
factoryBean.setAddress("http://localhost:8080/");
1313
Server server = factoryBean.create();
14-
14+
1515
System.out.println("Server ready...");
1616
Thread.sleep(60 * 1000);
1717
System.out.println("Server exiting");

core-java-9/src/main/java/com/baeldung/java9/language/PrivateInterface.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package com.baeldung.java9.language;
22

33
public interface PrivateInterface {
4-
4+
55
private static String staticPrivate() {
66
return "static private";
77
}
8-
8+
99
private String instancePrivate() {
1010
return "instance private";
1111
}
12-
13-
public default void check(){
12+
13+
public default void check() {
1414
String result = staticPrivate();
1515
if (!result.equals("static private"))
1616
throw new AssertionError("Incorrect result for static private interface method");

core-java-9/src/main/java/com/baeldung/java9/process/ProcessUtils.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
import java.time.Instant;
99
import java.util.stream.Stream;
1010

11-
1211
public class ProcessUtils {
1312

14-
public static String getClassPath(){
13+
public static String getClassPath() {
1514
String cp = System.getProperty("java.class.path");
16-
System.out.println("ClassPath is "+cp);
15+
System.out.println("ClassPath is " + cp);
1716
return cp;
1817
}
1918

20-
public static File getJavaCmd() throws IOException{
19+
public static File getJavaCmd() throws IOException {
2120
String javaHome = System.getProperty("java.home");
2221
File javaCmd;
23-
if(System.getProperty("os.name").startsWith("Win")){
22+
if (System.getProperty("os.name").startsWith("Win")) {
2423
javaCmd = new File(javaHome, "bin/java.exe");
25-
}else{
24+
} else {
2625
javaCmd = new File(javaHome, "bin/java");
2726
}
28-
if(javaCmd.canExecute()){
27+
if (javaCmd.canExecute()) {
2928
return javaCmd;
30-
}else{
29+
} else {
3130
throw new UnsupportedOperationException(javaCmd.getCanonicalPath() + " is not executable");
3231
}
3332
}
3433

35-
public static String getMainClass(){
34+
public static String getMainClass() {
3635
return System.getProperty("sun.java.command");
3736
}
3837

39-
public static String getSystemProperties(){
40-
StringBuilder sb = new StringBuilder();
41-
System.getProperties().forEach((s1, s2) -> sb.append(s1 +" - "+ s2) );
38+
public static String getSystemProperties() {
39+
StringBuilder sb = new StringBuilder();
40+
System.getProperties().forEach((s1, s2) -> sb.append(s1 + " - " + s2));
4241
return sb.toString();
4342
}
4443
}

core-java-9/src/main/java/com/baeldung/java9/process/ServiceMain.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public static void main(String[] args) throws InterruptedException {
88
ProcessHandle thisProcess = ProcessHandle.current();
99
long pid = thisProcess.getPid();
1010

11-
1211
Optional<String[]> opArgs = Optional.ofNullable(args);
1312
String procName = opArgs.map(str -> str.length > 0 ? str[0] : null).orElse(System.getProperty("sun.java.command"));
1413

core-java-9/src/test/java/com/baeldung/java9/Java9OptionalsStreamTest.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ public class Java9OptionalsStreamTest {
1919
public void filterOutPresentOptionalsWithFilter() {
2020
assertEquals(4, listOfOptionals.size());
2121

22-
List<String> filteredList = listOfOptionals.stream()
23-
.filter(Optional::isPresent)
24-
.map(Optional::get)
25-
.collect(Collectors.toList());
22+
List<String> filteredList = listOfOptionals.stream().filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
2623

2724
assertEquals(2, filteredList.size());
2825
assertEquals("foo", filteredList.get(0));
@@ -33,9 +30,7 @@ public void filterOutPresentOptionalsWithFilter() {
3330
public void filterOutPresentOptionalsWithFlatMap() {
3431
assertEquals(4, listOfOptionals.size());
3532

36-
List<String> filteredList = listOfOptionals.stream()
37-
.flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty())
38-
.collect(Collectors.toList());
33+
List<String> filteredList = listOfOptionals.stream().flatMap(o -> o.isPresent() ? Stream.of(o.get()) : Stream.empty()).collect(Collectors.toList());
3934
assertEquals(2, filteredList.size());
4035

4136
assertEquals("foo", filteredList.get(0));
@@ -46,9 +41,7 @@ public void filterOutPresentOptionalsWithFlatMap() {
4641
public void filterOutPresentOptionalsWithFlatMap2() {
4742
assertEquals(4, listOfOptionals.size());
4843

49-
List<String> filteredList = listOfOptionals.stream()
50-
.flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty))
51-
.collect(Collectors.toList());
44+
List<String> filteredList = listOfOptionals.stream().flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty)).collect(Collectors.toList());
5245
assertEquals(2, filteredList.size());
5346

5447
assertEquals("foo", filteredList.get(0));
@@ -59,9 +52,7 @@ public void filterOutPresentOptionalsWithFlatMap2() {
5952
public void filterOutPresentOptionalsWithJava9() {
6053
assertEquals(4, listOfOptionals.size());
6154

62-
List<String> filteredList = listOfOptionals.stream()
63-
.flatMap(Optional::stream)
64-
.collect(Collectors.toList());
55+
List<String> filteredList = listOfOptionals.stream().flatMap(Optional::stream).collect(Collectors.toList());
6556

6657
assertEquals(2, filteredList.size());
6758
assertEquals("foo", filteredList.get(0));

core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.baeldung.java9;
2-
2+
33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertSame;
55

@@ -13,7 +13,6 @@
1313

1414
public class MultiResultionImageTest {
1515

16-
1716
@Test
1817
public void baseMultiResImageTest() {
1918
int baseIndex = 1;
@@ -38,10 +37,8 @@ private static int getSize(int i) {
3837
return 8 * (i + 1);
3938
}
4039

41-
4240
private static BufferedImage createImage(int i) {
43-
return new BufferedImage(getSize(i), getSize(i),
44-
BufferedImage.TYPE_INT_RGB);
41+
return new BufferedImage(getSize(i), getSize(i), BufferedImage.TYPE_INT_RGB);
4542
}
4643

4744
}
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package com.baeldung.java9.httpclient;
2-
3-
1+
package com.baeldung.java9.httpclient;
42

53
import static java.net.HttpURLConnection.HTTP_OK;
64
import static org.junit.Assert.assertTrue;
@@ -28,35 +26,35 @@
2826

2927
public class SimpleHttpRequestsTest {
3028

31-
private URI httpURI;
32-
29+
private URI httpURI;
30+
3331
@Before
3432
public void init() throws URISyntaxException {
3533
httpURI = new URI("http://www.baeldung.com/");
3634
}
3735

3836
@Test
3937
public void quickGet() throws IOException, InterruptedException, URISyntaxException {
40-
HttpRequest request = HttpRequest.create( httpURI ).GET();
38+
HttpRequest request = HttpRequest.create(httpURI).GET();
4139
HttpResponse response = request.response();
4240
int responseStatusCode = response.statusCode();
4341
String responseBody = response.body(HttpResponse.asString());
44-
assertTrue("Get response status code is bigger then 400", responseStatusCode < 400);
42+
assertTrue("Get response status code is bigger then 400", responseStatusCode < 400);
4543
}
46-
44+
4745
@Test
48-
public void asynchronousGet() throws URISyntaxException, IOException, InterruptedException, ExecutionException{
46+
public void asynchronousGet() throws URISyntaxException, IOException, InterruptedException, ExecutionException {
4947
HttpRequest request = HttpRequest.create(httpURI).GET();
5048
long before = System.currentTimeMillis();
5149
CompletableFuture<HttpResponse> futureResponse = request.responseAsync();
52-
futureResponse.thenAccept( response -> {
50+
futureResponse.thenAccept(response -> {
5351
String responseBody = response.body(HttpResponse.asString());
54-
});
52+
});
5553
HttpResponse resp = futureResponse.get();
5654
HttpHeaders hs = resp.headers();
57-
assertTrue("There should be more then 1 header.", hs.map().size() >1);
55+
assertTrue("There should be more then 1 header.", hs.map().size() > 1);
5856
}
59-
57+
6058
@Test
6159
public void postMehtod() throws URISyntaxException, IOException, InterruptedException {
6260
HttpRequest.Builder requestBuilder = HttpRequest.create(httpURI);
@@ -66,61 +64,63 @@ public void postMehtod() throws URISyntaxException, IOException, InterruptedExce
6664
int statusCode = response.statusCode();
6765
assertTrue("HTTP return code", statusCode == HTTP_OK);
6866
}
69-
67+
7068
@Test
71-
public void configureHttpClient() throws NoSuchAlgorithmException, URISyntaxException, IOException, InterruptedException{
69+
public void configureHttpClient() throws NoSuchAlgorithmException, URISyntaxException, IOException, InterruptedException {
7270
CookieManager cManager = new CookieManager();
7371
cManager.setCookiePolicy(CookiePolicy.ACCEPT_ORIGINAL_SERVER);
74-
75-
SSLParameters sslParam = new SSLParameters (new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" }, new String[] { "TLSv1.2" });
76-
72+
73+
SSLParameters sslParam = new SSLParameters(new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" }, new String[] { "TLSv1.2" });
74+
7775
HttpClient.Builder hcBuilder = HttpClient.create();
7876
hcBuilder.cookieManager(cManager).sslContext(SSLContext.getDefault()).sslParameters(sslParam);
7977
HttpClient httpClient = hcBuilder.build();
8078
HttpRequest.Builder reqBuilder = httpClient.request(new URI("https://www.facebook.com"));
81-
79+
8280
HttpRequest request = reqBuilder.followRedirects(HttpClient.Redirect.ALWAYS).GET();
8381
HttpResponse response = request.response();
8482
int statusCode = response.statusCode();
8583
assertTrue("HTTP return code", statusCode == HTTP_OK);
8684
}
87-
88-
SSLParameters getDefaultSSLParameters() throws NoSuchAlgorithmException{
85+
86+
SSLParameters getDefaultSSLParameters() throws NoSuchAlgorithmException {
8987
SSLParameters sslP1 = SSLContext.getDefault().getSupportedSSLParameters();
90-
String [] proto = sslP1.getApplicationProtocols();
91-
String [] cifers = sslP1.getCipherSuites();
88+
String[] proto = sslP1.getApplicationProtocols();
89+
String[] cifers = sslP1.getCipherSuites();
9290
System.out.println(printStringArr(proto));
9391
System.out.println(printStringArr(cifers));
9492
return sslP1;
9593
}
96-
97-
String printStringArr(String ... args ){
98-
if(args == null){
94+
95+
String printStringArr(String... args) {
96+
if (args == null) {
9997
return null;
10098
}
10199
StringBuilder sb = new StringBuilder();
102-
for (String s : args){
100+
for (String s : args) {
103101
sb.append(s);
104102
sb.append("\n");
105103
}
106104
return sb.toString();
107105
}
108-
109-
String printHeaders(HttpHeaders h){
110-
if(h == null){
106+
107+
String printHeaders(HttpHeaders h) {
108+
if (h == null) {
111109
return null;
112110
}
113-
114-
StringBuilder sb = new StringBuilder();
115-
Map<String, List<String>> hMap = h.map();
116-
for(String k : hMap.keySet()){
117-
sb.append(k).append(":");
118-
List<String> l = hMap.get(k);
119-
if( l != null ){
120-
l.forEach( s -> { sb.append(s).append(","); } );
121-
}
122-
sb.append("\n");
123-
}
124-
return sb.toString();
111+
112+
StringBuilder sb = new StringBuilder();
113+
Map<String, List<String>> hMap = h.map();
114+
for (String k : hMap.keySet()) {
115+
sb.append(k).append(":");
116+
List<String> l = hMap.get(k);
117+
if (l != null) {
118+
l.forEach(s -> {
119+
sb.append(s).append(",");
120+
});
121+
}
122+
sb.append("\n");
123+
}
124+
return sb.toString();
125125
}
126126
}

core-java-9/src/test/java/com/baeldung/java9/language/TryWithResourcesTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class TryWithResourcesTest {
77

88
static int closeCount = 0;
99

10-
static class MyAutoCloseable implements AutoCloseable{
10+
static class MyAutoCloseable implements AutoCloseable {
1111
final FinalWrapper finalWrapper = new FinalWrapper();
1212

1313
public void close() {
@@ -57,7 +57,6 @@ public void tryWithResourcesTest() {
5757
assertEquals("Expected and Actual does not match", 5, closeCount);
5858
}
5959

60-
6160
static class CloseableException extends Exception implements AutoCloseable {
6261
@Override
6362
public void close() {
@@ -66,5 +65,3 @@ public void close() {
6665
}
6766

6867
}
69-
70-

0 commit comments

Comments
 (0)