Skip to content

Commit 75f2393

Browse files
committed
chore: spotless code fix with new indent
1 parent 9929f93 commit 75f2393

29 files changed

+596
-572
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_size = 2
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.{kt,kts}]
11+
kotlin_imports_layout = ascii

src/main/java/JavaApp.java

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,27 @@ public class JavaApp {
1616

1717
public static void main(String[] args) throws Exception {
1818

19-
final var lineSep = System.lineSeparator();
19+
final var lineSep = System.lineSeparator();
2020

2121
out.printf("%n✧✧✧✧✧ Processes ✧✧✧✧✧%n");
22-
var ps = ProcessHandle.allProcesses()
23-
.sorted(ProcessHandle::compareTo)
24-
.toList();
25-
ps.forEach(p -> {
26-
var pInfo = p.pid() + " : " + p.info();
27-
out.println(pInfo);
28-
});
22+
var ps = ProcessHandle.allProcesses().sorted(ProcessHandle::compareTo).toList();
23+
ps.forEach(
24+
p -> {
25+
var pInfo = p.pid() + " : " + p.info();
26+
out.println(pInfo);
27+
});
2928

3029
out.printf("%n✧✧✧✧✧ Trust stores ✧✧✧✧✧%n");
3130
var tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
3231
tmf.init((KeyStore) null);
33-
var issuers = Arrays.stream(tmf.getTrustManagers()).flatMap(tm -> {
34-
var x509Tm = (X509TrustManager) tm;
35-
return Arrays.stream(x509Tm.getAcceptedIssuers());
36-
}).toList();
32+
var issuers =
33+
Arrays.stream(tmf.getTrustManagers())
34+
.flatMap(
35+
tm -> {
36+
var x509Tm = (X509TrustManager) tm;
37+
return Arrays.stream(x509Tm.getAcceptedIssuers());
38+
})
39+
.toList();
3740
issuers.forEach(cert -> out.println(cert.getIssuerX500Principal()));
3841

3942
out.printf("%n✧✧✧✧✧ Dns Resolution ✧✧✧✧✧%n");
@@ -55,30 +58,40 @@ public static void main(String[] args) throws Exception {
5558
}
5659

5760
out.printf("%n✧✧✧✧✧ Env Variables ✧✧✧✧✧%n");
58-
var env = System.getenv();
61+
var env = System.getenv();
5962
env.forEach((k, v) -> out.println(k + " : " + v));
6063

6164
out.printf("%n✧✧✧✧✧ System Properties ✧✧✧✧✧%n");
6265
var props = System.getProperties();
6366
props.forEach((k, v) -> out.println(k + " : " + v));
6467

6568
var lineSepHex = HexFormat.of().formatHex(lineSep.getBytes(StandardCharsets.UTF_8));
66-
out.printf("%n✧✧✧✧✧ LineSeparator = %s%n", lineSepHex);
69+
out.printf("%n✧✧✧✧✧ LineSeparator = 0x%s%n", lineSepHex);
6770
out.printf("%n✧✧✧✧✧ File PathSeparator = %s%n", File.pathSeparator);
6871

69-
var stats = """
72+
var stats =
73+
"""
7074
+------------------------+
71-
| Processes : %5d |
72-
| Dns Addresses : %5d |
73-
| Trust Stores : %5d |
74-
| TimeZones : %5d |
75-
| CharSets : %5d |
76-
| Locales : %5d |
77-
| Env Vars : %5d |
78-
| Sys Props : %5d |
75+
| Processes : %-5d |
76+
| Dns Addresses : %-5d |
77+
| Trust Stores : %-5d |
78+
| TimeZones : %-5d |
79+
| CharSets : %-5d |
80+
| Locales : %-5d |
81+
| Env Vars : %-5d |
82+
| Sys Props : %-5d |
7983
+------------------------+
80-
""".formatted(ps.size(), dns.size(), issuers.size(), tz.size(), cs.size(),locales.length, env.size(),props.size());
84+
"""
85+
.formatted(
86+
ps.size(),
87+
dns.size(),
88+
issuers.size(),
89+
tz.size(),
90+
cs.size(),
91+
locales.length,
92+
env.size(),
93+
props.size());
8194

8295
out.println(stats);
8396
}
84-
}
97+
}

src/main/java/dev/suresh/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ record PersonX(Person p, int score) {}
3434

3535
public static void main(String[] args) throws Exception {
3636

37-
var textBlock = """
37+
var textBlock =
38+
"""
3839
This is a textBlock
3940
example \t introduced \\n in
4041
\s Java 15. \\n It \\

src/main/java/dev/suresh/adt/Records.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414

1515
public class Records {
1616

17-
public static void main(String[] args) throws Exception{
17+
public static void main(String[] args) throws Exception {
1818
run();
1919
}
2020

21-
public static void run() throws Exception{
21+
public static void run() throws Exception {
2222
amberReflections();
2323
serializeRecord();
2424
}
2525

2626
private static void amberReflections() {
27-
var sealedClazz= Result.class;
27+
var sealedClazz = Result.class;
2828
out.println("Result (Interface) -> " + sealedClazz.isInterface());
2929
out.println("Result (Sealed Class) -> " + sealedClazz.isSealed());
3030

3131
for (Class<?> permittedSubclass : sealedClazz.getPermittedSubclasses()) {
3232
out.println("\nPermitted Subclass : " + permittedSubclass.getName());
33-
if(permittedSubclass.isRecord()) {
33+
if (permittedSubclass.isRecord()) {
3434
out.println(permittedSubclass.getSimpleName() + " record components are,");
3535
for (RecordComponent rc : permittedSubclass.getRecordComponents()) {
3636
out.println(rc);
@@ -45,33 +45,30 @@ private static void serializeRecord() throws Exception {
4545
record Lang(String name, int age) implements Serializable {
4646
Lang {
4747
requireNonNull(name);
48-
if(age <= 0) throw new IllegalArgumentException("Invalid age " + age);
48+
if (age <= 0) throw new IllegalArgumentException("Invalid age " + age);
4949
}
5050
}
5151

5252
var serialFile = Files.createTempFile("record-serial", "data").toFile();
5353
serialFile.deleteOnExit();
5454

5555
try (var oos = new ObjectOutputStream(new FileOutputStream(serialFile))) {
56-
List<Record> recs = List.of(
57-
new Lang("Java", 25),
58-
(Record) Result.success(100)
59-
);
56+
List<Record> recs = List.of(new Lang("Java", 25), (Record) Result.success(100));
6057

6158
for (Record rec : recs) {
62-
out.println("Serializing record: " + rec);
59+
out.println("Serializing record: " + rec);
6360
oos.writeObject(rec);
6461
}
65-
oos.writeObject(null); //EOF
62+
oos.writeObject(null); // EOF
6663
}
6764

68-
try (var ois = new ObjectInputStream( new FileInputStream(serialFile))) {
65+
try (var ois = new ObjectInputStream(new FileInputStream(serialFile))) {
6966
Object rec;
70-
while((rec = ois.readObject()) != null) {
67+
while ((rec = ois.readObject()) != null) {
7168
out.println("Deserialized record: " + rec);
72-
if(rec instanceof Lang l) {
69+
if (rec instanceof Lang l) {
7370
out.println("Lang name: " + l.name);
74-
}else if(rec instanceof Result r) {
71+
} else if (rec instanceof Result r) {
7572
out.println("Result value: " + r.getOrNull());
7673
} else {
7774
System.err.println("Invalid serialized data. Expected Result, but found " + rec);

src/main/java/dev/suresh/adt/ResultType.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ default Throwable exceptionOrNull() {
3535
}
3636
}
3737

38+
39+
record Success<T>(T value) implements Result<T> { }
40+
41+
record Failure<T>(Throwable error) implements Result<T> { }
42+
3843
/**
3944
* A value that represents either a success or a failure, including an associated value in each case.
4045
*/
@@ -68,7 +73,3 @@ static <T> void printResult(Result<T> r) {
6873
);
6974
}
7075
}
71-
72-
record Success<T>(T value) implements Result<T> { }
73-
74-
record Failure<T>(Throwable error) implements Result<T> { }

src/main/java/dev/suresh/generics/Employee.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ public String toString() {
2121
""".formatted(name);
2222
}
2323
}
24-

src/main/java/dev/suresh/jte/Config.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ public Config() {
1313
version = Objects.requireNonNullElse(version, System.getProperty("java.version"));
1414
}
1515
}
16-

src/main/kotlin/Main.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
fun main() {
2-
println("Hello Kotlin! ${App.KOTLIN_VERSION}")
3-
val s: Result<Int> = Result.Success(10)
4-
when (s) {
5-
is Result.Success -> 1
6-
is Error -> 2
7-
is Result.Error.RecException -> TODO()
8-
is Result.Error.NonRecException -> TODO()
9-
Result.InProgress -> TODO()
10-
}.exhaustive
2+
println("Hello Kotlin! ${App.KOTLIN_VERSION}")
3+
val s: Result<Int> = Result.Success(10)
4+
when (s) {
5+
is Result.Success -> 1
6+
is Error -> 2
7+
is Result.Error.RecException -> TODO()
8+
is Result.Error.NonRecException -> TODO()
9+
Result.InProgress -> TODO()
10+
}.exhaustive
1111

12-
println("Security Manager Allowed: ${System.getProperty("java.security.manager")}")
13-
println("Security Manager: ${System.getSecurityManager()}")
12+
println("Security Manager Allowed: ${System.getProperty("java.security.manager")}")
13+
println("Security Manager: ${System.getSecurityManager()}")
1414
}
1515

1616
sealed class Result<out T> {
17-
data class Success<T : Any>(val data: T) : Result<T>()
18-
sealed class Error(val exec: Exception) : Result<Nothing>() {
19-
class RecException(val e: Exception) : Error(e)
20-
class NonRecException(val e: Exception) : Error(e)
21-
}
17+
data class Success<T : Any>(val data: T) : Result<T>()
18+
sealed class Error(val exec: Exception) : Result<Nothing>() {
19+
class RecException(val e: Exception) : Error(e)
20+
class NonRecException(val e: Exception) : Error(e)
21+
}
2222

23-
object InProgress : Result<Nothing>()
23+
object InProgress : Result<Nothing>()
2424
}
2525

2626
val <T> T.exhaustive get() = this

src/main/kotlin/dev/suresh/atomic/Batch.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import java.util.concurrent.atomic.*
1010
*/
1111
data class Counter(@Volatile private var count: Int = 0) {
1212

13-
companion object {
14-
private val COUNT = AtomicIntegerFieldUpdater.newUpdater(Counter::class.java, "count")
15-
}
13+
companion object {
14+
private val COUNT = AtomicIntegerFieldUpdater.newUpdater(Counter::class.java, "count")
15+
}
1616

17-
fun increment(delta: Int) = COUNT.addAndGet(this, delta)
17+
fun increment(delta: Int) = COUNT.addAndGet(this, delta)
1818
}
1919

2020
fun main() {
2121

22-
println(Counter().apply { increment(100) })
22+
println(Counter().apply { increment(100) })
2323
}

src/main/kotlin/dev/suresh/cli/Main.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import com.jakewharton.crossword.*
44

55
fun main() {
66

7-
val canvas = TextCanvas(30, 30)
8-
(1..10).forEach {
9-
canvas.write(0, 0, "\u001B[31mX\u001B[0m")
10-
canvas.write(0, 2, "\u001B[34mO\u001B[0m")
11-
canvas.write(1, 0, "Hello World $it")
12-
println(canvas.toString())
13-
Thread.sleep(100)
14-
println("""\x1B[${canvas.height}F""")
15-
}
7+
val canvas = TextCanvas(30, 30)
8+
(1..10).forEach {
9+
canvas.write(0, 0, "\u001B[31mX\u001B[0m")
10+
canvas.write(0, 2, "\u001B[34mO\u001B[0m")
11+
canvas.write(1, 0, "Hello World $it")
12+
println(canvas.toString())
13+
Thread.sleep(100)
14+
println("""\x1B[${canvas.height}F""")
15+
}
1616
}

0 commit comments

Comments
 (0)