Skip to content

Commit f354f9e

Browse files
author
eugenp
committed
minor formatting work
1 parent 7194d8b commit f354f9e

10 files changed

Lines changed: 22 additions & 35 deletions

File tree

‎core-java/src/main/java/com/baeldung/hashing/SHA256Hashing.java‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.baeldung.hashing;
22

3-
43
import com.google.common.hash.Hashing;
54
import org.apache.commons.codec.digest.DigestUtils;
65
import org.bouncycastle.util.encoders.Hex;
@@ -11,17 +10,14 @@
1110

1211
public class SHA256Hashing {
1312

14-
public static String HashWithJavaMessageDigest(final String originalString)
15-
throws NoSuchAlgorithmException {
13+
public static String HashWithJavaMessageDigest(final String originalString) throws NoSuchAlgorithmException {
1614
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
17-
final byte[] encodedhash = digest.digest(
18-
originalString.getBytes(StandardCharsets.UTF_8));
15+
final byte[] encodedhash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
1916
return bytesToHex(encodedhash);
2017
}
2118

2219
public static String HashWithGuava(final String originalString) {
23-
final String sha256hex = Hashing.sha256().hashString(
24-
originalString, StandardCharsets.UTF_8).toString();
20+
final String sha256hex = Hashing.sha256().hashString(originalString, StandardCharsets.UTF_8).toString();
2521
return sha256hex;
2622
}
2723

@@ -30,11 +26,9 @@ public static String HashWithApacheCommons(final String originalString) {
3026
return sha256hex;
3127
}
3228

33-
public static String HashWithBouncyCastle(final String originalString)
34-
throws NoSuchAlgorithmException {
29+
public static String HashWithBouncyCastle(final String originalString) throws NoSuchAlgorithmException {
3530
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
36-
final byte[] hash = digest.digest(
37-
originalString.getBytes(StandardCharsets.UTF_8));
31+
final byte[] hash = digest.digest(originalString.getBytes(StandardCharsets.UTF_8));
3832
final String sha256hex = new String(Hex.encode(hash));
3933
return sha256hex;
4034
}
@@ -43,7 +37,8 @@ private static String bytesToHex(byte[] hash) {
4337
StringBuffer hexString = new StringBuffer();
4438
for (int i = 0; i < hash.length; i++) {
4539
String hex = Integer.toHexString(0xff & hash[i]);
46-
if(hex.length() == 1) hexString.append('0');
40+
if (hex.length() == 1)
41+
hexString.append('0');
4742
hexString.append(hex);
4843
}
4944
return hexString.toString();

‎core-java/src/main/java/com/baeldung/java/nio2/visitor/FileVisitorImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
1919
}
2020

2121
@Override
22-
public FileVisitResult visitFileFailed(Path file, IOException exc) {
22+
public FileVisitResult visitFileFailed(Path file, IOException exc) {
2323
return null;
2424
}
2525

2626
@Override
27-
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
27+
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
2828
return null;
2929
}
3030
}

‎core-java/src/test/java/com/baeldung/generics/GenericsTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class GenericsTest {
1212
// testing the generic method with Integer
1313
@Test
1414
public void givenArrayOfIntegers_thanListOfIntegersReturnedOK() {
15-
Integer[] intArray = {1, 2, 3, 4, 5};
15+
Integer[] intArray = { 1, 2, 3, 4, 5 };
1616
List<Integer> list = Generics.fromArrayToList(intArray);
1717

1818
assertThat(list, hasItems(intArray));
@@ -21,7 +21,7 @@ public void givenArrayOfIntegers_thanListOfIntegersReturnedOK() {
2121
// testing the generic method with String
2222
@Test
2323
public void givenArrayOfStrings_thanListOfStringsReturnedOK() {
24-
String[] stringArray = {"hello1", "hello2", "hello3", "hello4", "hello5"};
24+
String[] stringArray = { "hello1", "hello2", "hello3", "hello4", "hello5" };
2525
List<String> list = Generics.fromArrayToList(stringArray);
2626

2727
assertThat(list, hasItems(stringArray));
@@ -32,7 +32,7 @@ public void givenArrayOfStrings_thanListOfStringsReturnedOK() {
3232
// extend Number it will fail to compile
3333
@Test
3434
public void givenArrayOfIntegersAndNumberUpperBound_thanListOfIntegersReturnedOK() {
35-
Integer[] intArray = {1, 2, 3, 4, 5};
35+
Integer[] intArray = { 1, 2, 3, 4, 5 };
3636
List<Integer> list = Generics.fromArrayToListWithUpperBound(intArray);
3737

3838
assertThat(list, hasItems(intArray));

‎core-java/src/test/java/com/baeldung/hashing/SHA256HashingTest.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
import static org.junit.Assert.*;
66

7-
87
public class SHA256HashingTest {
98

109
private static String originalValue = "abc123";
11-
private static String hashedValue =
12-
"6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090";
10+
private static String hashedValue = "6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090";
1311

1412
@Test
1513
public void testHashWithJavaMessageDigest() throws Exception {

‎core-java/src/test/java/com/baeldung/java/conversion/StringConversionTest.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ public void whenConvertedToLocalDateTime_thenCorrect() {
119119
int afterConvCalendarDay = 03;
120120
Month afterConvCalendarMonth = Month.DECEMBER;
121121
int afterConvCalendarYear = 2007;
122-
LocalDateTime afterConvDate
123-
= new UseLocalDateTime().getLocalDateTimeUsingParseMethod(str);
122+
LocalDateTime afterConvDate = new UseLocalDateTime().getLocalDateTimeUsingParseMethod(str);
124123

125124
assertEquals(afterConvDate.getDayOfMonth(), afterConvCalendarDay);
126125
assertEquals(afterConvDate.getMonth(), afterConvCalendarMonth);

‎core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public static void main(String[] args) {
6666
AsyncEchoServer server = new AsyncEchoServer();
6767
server.runServer();
6868
}
69+
6970
public static Process start() throws IOException, InterruptedException {
7071
String javaHome = System.getProperty("java.home");
7172
String javaBin = javaHome + File.separator + "bin" + File.separator + "java";

‎core-java/src/test/java/com/baeldung/java/nio2/async/AsyncEchoServer2.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public void failed(Throwable exc, Map<String, Object> attachment) {
8181

8282
}
8383

84-
8584
public static void main(String[] args) {
8685
new AsyncEchoServer2();
8786
}

‎core-java/src/test/java/com/baeldung/java/nio2/async/AsyncFileTest.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ public void givenPathAndContent_whenWritesToFileWithFuture_thenCorrect() throws
8282
public void givenPathAndContent_whenWritesToFileWithHandler_thenCorrect() throws IOException {
8383
String fileName = UUID.randomUUID().toString();
8484
Path path = Paths.get(fileName);
85-
AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE,StandardOpenOption.DELETE_ON_CLOSE);
86-
85+
AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(path, StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.DELETE_ON_CLOSE);
8786

8887
ByteBuffer buffer = ByteBuffer.allocate(1024);
8988
buffer.put("hello world".getBytes());

‎core-java/src/test/java/org/baeldung/java/io/JavaFileUnitTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class JavaFileUnitTest {
2020

2121
private static final String TEMP_DIR = "src/test/resources/temp" + UUID.randomUUID().toString();
2222

23-
2423
@BeforeClass
2524
public static void setup() throws IOException {
2625
Files.createDirectory(Paths.get(TEMP_DIR));

‎core-java/src/test/java/org/baeldung/java/sorting/Employee.java‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package org.baeldung.java.sorting;
22

33
public class Employee implements Comparable {
4-
4+
55
private String name;
66
private int age;
77
private double salary;
88

99
public Employee(String name, int age, double salary) {
10-
this.name = name;
11-
this.age = age;
10+
this.name = name;
11+
this.age = age;
1212
this.salary = salary;
1313
}
1414

@@ -35,7 +35,7 @@ public double getSalary() {
3535
public void setSalary(double salary) {
3636
this.salary = salary;
3737
}
38-
38+
3939
@Override
4040
public boolean equals(Object obj) {
4141
return ((Employee) obj).getName().equals(getName());
@@ -46,13 +46,10 @@ public int compareTo(Object o) {
4646
Employee e = (Employee) o;
4747
return getName().compareTo(e.getName());
4848
}
49-
49+
5050
@Override
5151
public String toString() {
52-
return new StringBuffer()
53-
.append("(").append(getName())
54-
.append(getAge()).append(",")
55-
.append(getSalary()).append(")").toString();
52+
return new StringBuffer().append("(").append(getName()).append(getAge()).append(",").append(getSalary()).append(")").toString();
5653
}
5754

5855
}

0 commit comments

Comments
 (0)