Skip to content

Commit f3ef6ec

Browse files
committed
Format/Streamify
1 parent 18ade9f commit f3ef6ec

Some content is hidden

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

52 files changed

+332
-180
lines changed

annotations/AtUnitExample1.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public int methodTwo() {
2323
@Test private boolean m3() { return true; }
2424
// Shows output for failure:
2525
@Test boolean failureTest() { return false; }
26-
@Test boolean anotherDisappointment() { return false; }
26+
@Test boolean anotherDisappointment() {
27+
return false;
28+
}
2729
}
2830
/* Output:
2931
annotations.AtUnitExample1

annotations/AtUnitExample4.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ public class AtUnitExample4 {
1515
"middle, and then thin again at the far end.";
1616
private String word;
1717
private Random rand = new Random(); // Time-based seed
18-
public AtUnitExample4(String word) { this.word = word; }
18+
public AtUnitExample4(String word) {
19+
this.word = word;
20+
}
1921
public String getWord() { return word; }
2022
public String scrambleWord() {
2123
List<Character> chars =
22-
Arrays.asList(ConvertTo.boxed(word.toCharArray()));
24+
Arrays.asList(
25+
ConvertTo.boxed(word.toCharArray()));
2326
Collections.shuffle(chars, rand);
2427
StringBuilder result = new StringBuilder();
2528
for(char ch : chars)
@@ -41,7 +44,7 @@ public String scrambleWord() {
4144
return getWord().equals("are");
4245
}
4346
@Test boolean scramble1() {
44-
// Change to specific seed to get verifiable results:
47+
// Use specific seed to get verifiable results:
4548
rand = new Random(47);
4649
System.out.println("'" + getWord() + "'");
4750
String scrambled = scrambleWord();

annotations/AtUnitExample5.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
public class AtUnitExample5 {
1313
private String text;
14-
public AtUnitExample5(String text) { this.text = text; }
14+
public AtUnitExample5(String text) {
15+
this.text = text;
16+
}
1517
@Override
1618
public String toString() { return text; }
1719
@TestProperty static PrintWriter output;

annotations/AtUnitExternalTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
import onjava.atunit.*;
1010
import onjava.*;
1111

12-
public class AtUnitExternalTest extends AtUnitExample1 {
12+
public class
13+
AtUnitExternalTest extends AtUnitExample1 {
1314
@Test boolean tMethodOne() {
1415
return methodOne().equals("This is methodOne");
1516
}
16-
@Test boolean tMethodTwo() { return methodTwo() == 2; }
17+
@Test boolean tMethodTwo() {
18+
return methodTwo() == 2;
19+
}
1720
}
1821
/* Output:
1922
annotations.AtUnitExternalTest

annotations/PasswordUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ public boolean validatePassword(String passwd) {
1212
}
1313
@UseCase(id = 48)
1414
public String encryptPassword(String passwd) {
15-
return new StringBuilder(passwd).reverse().toString();
15+
return new StringBuilder(passwd)
16+
.reverse().toString();
1617
}
1718
@UseCase(id = 49, description =
1819
"New passwords can't equal previously used ones")

annotations/StackLStringTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import onjava.atunit.*;
1010
import onjava.*;
1111

12-
public class StackLStringTest extends StackL<String> {
12+
public class
13+
StackLStringTest extends StackL<String> {
1314
@Test void tPush() {
1415
push("one");
1516
assert top().equals("one");

arrays/ArrayOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
public class ArrayOptions {
1010
public static void main(String[] args) {
1111
// Arrays of objects:
12-
BerylliumSphere[] a; // Local uninitialized variable
12+
BerylliumSphere[] a; // Uninitialized local
1313
BerylliumSphere[] b = new BerylliumSphere[5];
1414

1515
// The references inside the array are

arrays/CollectionComparison.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ class BerylliumSphere {
1010
private static long counter;
1111
private final long id = counter++;
1212
@Override
13-
public String toString() { return "Sphere " + id; }
13+
public String toString() {
14+
return "Sphere " + id;
15+
}
1416
}
1517

1618
public class CollectionComparison {
1719
public static void main(String[] args) {
18-
BerylliumSphere[] spheres = new BerylliumSphere[10];
20+
BerylliumSphere[] spheres =
21+
new BerylliumSphere[10];
1922
for(int i = 0; i < 5; i++)
2023
spheres[i] = new BerylliumSphere();
2124
show(spheres);

arrays/TestCount.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static void main(String[] args) {
2020
show(a1);
2121
a1 = new Count.Boolean().array(SZ + 2);
2222
show(a1);
23-
boolean[] a1b = new Count.Pboolean().array(SZ + 3);
23+
boolean[] a1b =
24+
new Count.Pboolean().array(SZ + 3);
2425
show(a1b);
2526

2627
System.out.println("Byte");
@@ -63,8 +64,9 @@ public static void main(String[] args) {
6364
int[] a5 = new int[SZ];
6465
Arrays.setAll(a5, new Count.Integer()::get);
6566
show(a5);
66-
Integer[] a5b = Stream.generate(new Count.Integer())
67-
.limit(SZ + 1).toArray(Integer[]::new);
67+
Integer[] a5b =
68+
Stream.generate(new Count.Integer())
69+
.limit(SZ + 1).toArray(Integer[]::new);
6870
show(a5b);
6971
a5b = new Count.Integer().array(SZ + 2);
7072
show(a5b);
@@ -105,8 +107,9 @@ public static void main(String[] args) {
105107
double[] a8 = new double[SZ];
106108
Arrays.setAll(a8, new Count.Double()::get);
107109
show(a8);
108-
Double[] a8b = Stream.generate(new Count.Double())
109-
.limit(SZ + 1).toArray(Double[]::new);
110+
Double[] a8b =
111+
Stream.generate(new Count.Double())
112+
.limit(SZ + 1).toArray(Double[]::new);
110113
show(a8b);
111114
a8b = new Count.Double().array(SZ + 2);
112115
show(a8b);

arrays/TestRand.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ public static void main(String[] args) {
2020
show(a1);
2121
a1 = new Rand.Boolean().array(SZ + 2);
2222
show(a1);
23-
boolean[] a1b = new Rand.Pboolean().array(SZ + 3);
23+
boolean[] a1b =
24+
new Rand.Pboolean().array(SZ + 3);
2425
show(a1b);
2526

2627
System.out.println("Byte");
@@ -63,8 +64,9 @@ public static void main(String[] args) {
6364
int[] a5 = new int[SZ];
6465
Arrays.setAll(a5, new Rand.Integer()::get);
6566
show(a5);
66-
Integer[] a5b = Stream.generate(new Rand.Integer())
67-
.limit(SZ + 1).toArray(Integer[]::new);
67+
Integer[] a5b =
68+
Stream.generate(new Rand.Integer())
69+
.limit(SZ + 1).toArray(Integer[]::new);
6870
show(a5b);
6971
a5b = new Rand.Integer().array(SZ + 2);
7072
show(a5b);
@@ -105,8 +107,9 @@ public static void main(String[] args) {
105107
double[] a8 = new double[SZ];
106108
Arrays.setAll(a8, new Rand.Double()::get);
107109
show(a8);
108-
Double[] a8b = Stream.generate(new Rand.Double())
109-
.limit(SZ + 1).toArray(Double[]::new);
110+
Double[] a8b =
111+
Stream.generate(new Rand.Double())
112+
.limit(SZ + 1).toArray(Double[]::new);
110113
show(a8b);
111114
a8b = new Rand.Double().array(SZ + 2);
112115
show(a8b);

0 commit comments

Comments
 (0)