Skip to content

Commit ca4230f

Browse files
committed
. d reformatted code and updated markdown snippets
1 parent 2477668 commit ca4230f

31 files changed

+143
-138
lines changed

approvaltests-util/docs/ArrayUtils.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ comparables.add(3.1415);
2121
comparables.add("Lars");
2222
Comparable[] comparableArray = ArrayUtils.toArray(comparables);
2323
```
24-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L101-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArray' title='Start of snippet'>anchor</a></sup>
24+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L105-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArray' title='Start of snippet'>anchor</a></sup>
2525
<!-- endSnippet -->
2626

2727
This works in almost all cases with the notable exceptions of empty arrays, some common interfaces
@@ -32,7 +32,7 @@ In which case you can always use the overloaded method
3232
```java
3333
Comparable[] array = ArrayUtils.toArray(comparables, Comparable.class);
3434
```
35-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L109-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArrayWithClass' title='Start of snippet'>anchor</a></sup>
35+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/ArrayUtilsTest.java#L113-L115' title='Snippet source file'>snippet source</a> | <a href='#snippet-toArrayWithClass' title='Start of snippet'>anchor</a></sup>
3636
<!-- endSnippet -->
3737

3838

approvaltests-util/docs/Features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ For Example Action3 has the single method:
5252
```java
5353
public void call(In1 a, In2 b, In3 c);
5454
```
55-
<sup><a href='/approvaltests-util/src/main/java/org/lambda/actions/Action3.java#L10-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-action3_call' title='Start of snippet'>anchor</a></sup>
55+
<sup><a href='/approvaltests-util/src/main/java/org/lambda/actions/Action3.java#L11-L13' title='Snippet source file'>snippet source</a> | <a href='#snippet-action3_call' title='Start of snippet'>anchor</a></sup>
5656
<!-- endSnippet -->
5757

5858
The first 3 have native java equivalents (that are hard to remember).

approvaltests-util/docs/StringUtils.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For example
2323
List<Integer> number = Arrays.asList(1, 2, 3, 4, 5);
2424
String text = StringUtils.join(number, ", ");
2525
```
26-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.java#L66-L69' title='Snippet source file'>snippet source</a> | <a href='#snippet-join_collection' title='Start of snippet'>anchor</a></sup>
26+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.java#L71-L74' title='Snippet source file'>snippet source</a> | <a href='#snippet-join_collection' title='Start of snippet'>anchor</a></sup>
2727
<!-- endSnippet -->
2828
will produce
2929
<!-- snippet: /approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.testJoinCollection.approved.txt -->
@@ -44,7 +44,7 @@ For example:
4444
List<Integer> number = Arrays.asList(1, 2, 3, 4, 5);
4545
String text = StringUtils.join(number, ", ", n -> StringUtils.padNumber(n, 3));
4646
```
47-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.java#L75-L78' title='Snippet source file'>snippet source</a> | <a href='#snippet-join_collection_with_lambda' title='Start of snippet'>anchor</a></sup>
47+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.java#L81-L84' title='Snippet source file'>snippet source</a> | <a href='#snippet-join_collection_with_lambda' title='Start of snippet'>anchor</a></sup>
4848
<!-- endSnippet -->
4949
will Produce
5050
<!-- snippet: /approvaltests-util-tests/src/test/java/com/spun/util/StringUtilsTest.testJoinCollectionWithFunction.approved.txt -->

approvaltests-util/docs/how_to/CaptureLogs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ StringBuffer log = SimpleLogger.logToString();
2525
new Sample().methodThatLogs();
2626
Approvals.verify(log);
2727
```
28-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/logger/SimpleLoggerTest.java#L35-L39' title='Snippet source file'>snippet source</a> | <a href='#snippet-log_to_string' title='Start of snippet'>anchor</a></sup>
28+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/logger/SimpleLoggerTest.java#L36-L40' title='Snippet source file'>snippet source</a> | <a href='#snippet-log_to_string' title='Start of snippet'>anchor</a></sup>
2929
<!-- endSnippet -->
3030

3131
## See also

approvaltests-util/docs/how_to/ExtendQueryable.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static Queryable<String> findFirstWordsOnly(List<String> words)
2020
});
2121
}
2222
```
23-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L36-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query' title='Start of snippet'>anchor</a></sup>
23+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L38-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query' title='Start of snippet'>anchor</a></sup>
2424
<!-- endSnippet -->
2525
You can add this to Queryable by implementing the `com.lambda.utils.Extendable` interface.
2626
<!-- snippet: implementing-extendable -->
@@ -35,7 +35,7 @@ public static class CustomQuery implements Extendable<List<String>>
3535
this.caller = caller;
3636
}
3737
```
38-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L20-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-implementing-extendable' title='Start of snippet'>anchor</a></sup>
38+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L20-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-implementing-extendable' title='Start of snippet'>anchor</a></sup>
3939
<!-- endSnippet -->
4040
Now you can add extension methods that are **not static**
4141
<!-- snippet: extendable-query -->
@@ -46,7 +46,7 @@ public Queryable<String> findFirstWordsOnly()
4646
return findFirstWordsOnly(caller);
4747
}
4848
```
49-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L30-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-extendable-query' title='Start of snippet'>anchor</a></sup>
49+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L31-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-extendable-query' title='Start of snippet'>anchor</a></sup>
5050
<!-- endSnippet -->
5151
and now you can call it as such
5252
<!-- snippet: custom-query-example -->
@@ -56,7 +56,7 @@ Queryable<String> list = Queryable.as("One fish", "two fish", "red fish", "blue
5656
Queryable<String> firstWordsOnlyWithExtension = list.select(String::toUpperCase).use(CustomQuery.class)
5757
.findFirstWordsOnly();
5858
```
59-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L56-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query-example' title='Start of snippet'>anchor</a></sup>
59+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L58-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query-example' title='Start of snippet'>anchor</a></sup>
6060
<!-- endSnippet -->
6161
whereas previously you had to use
6262
<!-- snippet: custom-query-example-static -->
@@ -65,7 +65,7 @@ whereas previously you had to use
6565
Queryable<String> firstWordsOnlyStatic = CustomQuery
6666
.findFirstWordsOnly(Query.select(list, String::toUpperCase));
6767
```
68-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L61-L64' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query-example-static' title='Start of snippet'>anchor</a></sup>
68+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L63-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-custom-query-example-static' title='Start of snippet'>anchor</a></sup>
6969
<!-- endSnippet -->
7070

7171
## See also

approvaltests-util/docs/how_to/LoadersAndSavers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void sendOutSeniorDiscounts(DataBase database, MailServer mailServer)
5252
}
5353
}
5454
```
55-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L68-L79' title='Snippet source file'>snippet source</a> | <a href='#snippet-step1' title='Start of snippet'>anchor</a></sup>
55+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L71-L82' title='Snippet source file'>snippet source</a> | <a href='#snippet-step1' title='Start of snippet'>anchor</a></sup>
5656
<!-- endSnippet -->
5757

5858
In this case, we want to replace the functions that use the DataBase object with Loaders :
@@ -72,7 +72,7 @@ public void senior_customer_list_includes_only_those_over_age_65()
7272
Approvals.verifyAll("", mailServer.getRecipients());
7373
}
7474
```
75-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L16-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-step0' title='Start of snippet'>anchor</a></sup>
75+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L16-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-step0' title='Start of snippet'>anchor</a></sup>
7676
<!-- endSnippet -->
7777

7878
This test works against a live database with a live mail server.
@@ -94,7 +94,7 @@ Now we dump the data resulting from a successful query so that we can create a f
9494
List<Customer> seniorCustomers = database.getSeniorCustomers();
9595
seniorCustomers.stream().forEach(System.out::println);
9696
```
97-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L47-L50' title='Snippet source file'>snippet source</a> | <a href='#snippet-step_capture_data' title='Start of snippet'>anchor</a></sup>
97+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L50-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-step_capture_data' title='Start of snippet'>anchor</a></sup>
9898
<!-- endSnippet -->
9999

100100
generates
@@ -116,7 +116,7 @@ Step 3: Create a result object populated with these values (or at least enough o
116116
List.of(new Customer("Bob, Jones, 123 Elm St., Tempe, AZ, 14-MAR-1958"),
117117
new Customer("Mary, Smith, 345 Oak St., Mason, VA, 04-MAY-1944"));
118118
```
119-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L59-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-step_fake_data' title='Start of snippet'>anchor</a></sup>
119+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/persistence/LoadersAndSaversExamplesTest.java#L62-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-step_fake_data' title='Start of snippet'>anchor</a></sup>
120120
<!-- endSnippet -->
121121

122122
### Step 4: In the original method, replace the function call with a Loader

approvaltests-util/docs/how_to/UseMutablesInLambdas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ scheduler.rsvp();
6161
i.set("Steve");
6262
scheduler.bookHotel();
6363
```
64-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/utils/MutableTest.java#L20-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-mutable_example' title='Start of snippet'>anchor</a></sup>
64+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/utils/MutableTest.java#L21-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-mutable_example' title='Start of snippet'>anchor</a></sup>
6565
<!-- endSnippet -->
6666

6767
Will produce the following:

approvaltests-util/docs/how_to/VarArgsWithAtleastOne.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Integer findSmallest(Integer... numbers)
2727
{ throw new IllegalArgumentException("you must have at least one number"); }
2828
// rest of the code
2929
```
30-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L20-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsRuntime' title='Start of snippet'>anchor</a></sup>
30+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L21-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsRuntime' title='Start of snippet'>anchor</a></sup>
3131
<!-- endSnippet -->
3232

3333
### Compile time solution
@@ -44,7 +44,7 @@ public Integer findSmallest(Integer first, Integer... numbers)
4444
Integer[] combined = ArrayUtils.combine(first, numbers);
4545
// rest of the code
4646
```
47-
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L29-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsCompileTime' title='Start of snippet'>anchor</a></sup>
47+
<sup><a href='/approvaltests-util-tests/src/test/java/com/spun/util/MinimumVarargSamples.java#L31-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-minimalVarargsCompileTime' title='Start of snippet'>anchor</a></sup>
4848
<!-- endSnippet -->
4949

5050
### Advantages

approvaltests-util/docs/reference/Query.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Integer[] numbers = Range.get(1, 20);
3131
Integer[] evenQueryNumbers = Query.where(numbers, n -> n % 2 == 0).orderBy(OrderBy.Order.Descending, n -> n)
3232
.asArray();
3333
```
34-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L37-L41' title='Snippet source file'>snippet source</a> | <a href='#snippet-query_example' title='Start of snippet'>anchor</a></sup>
34+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L39-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-query_example' title='Start of snippet'>anchor</a></sup>
3535
<!-- endSnippet -->
3636

3737
Here is the exact same function but using Java Streams:
@@ -42,7 +42,7 @@ Here is the exact same function but using Java Streams:
4242
Integer[] evenStreamNumbers = Arrays.stream(numbers).filter(n -> n % 2 == 0)
4343
.sorted((o1, o2) -> o2.compareTo(o1)).toArray(Integer[]::new);
4444
```
45-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L42-L45' title='Snippet source file'>snippet source</a> | <a href='#snippet-stream_example' title='Start of snippet'>anchor</a></sup>
45+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L44-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-stream_example' title='Start of snippet'>anchor</a></sup>
4646
<!-- endSnippet -->
4747

4848
Another example using sum() vs. reduce():
@@ -53,7 +53,7 @@ Another example using sum() vs. reduce():
5353
String[] names = {"Llewellyn", "Scott"};
5454
int lengthsFromQuery = Query.sum(names, n -> n.length()).intValue();
5555
```
56-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L49-L52' title='Snippet source file'>snippet source</a> | <a href='#snippet-query_sum_example' title='Start of snippet'>anchor</a></sup>
56+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L51-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-query_sum_example' title='Start of snippet'>anchor</a></sup>
5757
<!-- endSnippet -->
5858

5959
Here is the exact same function but using Java Streams:
@@ -63,7 +63,7 @@ Here is the exact same function but using Java Streams:
6363
```java
6464
int lengthsFromStream = (int) Arrays.stream(names).map(n -> n.length()).reduce(0, (a, b) -> a + b);
6565
```
66-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L53-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-stream_sum_example' title='Start of snippet'>anchor</a></sup>
66+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L55-L57' title='Snippet source file'>snippet source</a> | <a href='#snippet-stream_sum_example' title='Start of snippet'>anchor</a></sup>
6767
<!-- endSnippet -->
6868

6969
#### Other benefits
@@ -82,7 +82,7 @@ Using Query:
8282
```java
8383
List<String> strings = Query.select(numbers, n -> "" + n);
8484
```
85-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L60-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-list_is_queryable' title='Start of snippet'>anchor</a></sup>
85+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L62-L64' title='Snippet source file'>snippet source</a> | <a href='#snippet-list_is_queryable' title='Start of snippet'>anchor</a></sup>
8686
<!-- endSnippet -->
8787

8888
Using Streams:
@@ -91,7 +91,7 @@ Using Streams:
9191
```java
9292
List<String> strings2 = Arrays.stream(numbers).map(n -> "" + n).collect(Collectors.toList());
9393
```
94-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L63-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-list_from_stream' title='Start of snippet'>anchor</a></sup>
94+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryTest.java#L65-L67' title='Snippet source file'>snippet source</a> | <a href='#snippet-list_from_stream' title='Start of snippet'>anchor</a></sup>
9595
<!-- endSnippet -->
9696

9797
### API
@@ -119,7 +119,7 @@ Queryable<String> names = Queryable.as("Now is the time", "Fourscore and seven y
119119
"When in the course of human events");
120120
Queryable<String> allNames = names.selectMany(n -> Arrays.asList(n.split(" "))).orderBy(n -> n);
121121
```
122-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L143-L147' title='Snippet source file'>snippet source</a> | <a href='#snippet-queryable_select_many' title='Start of snippet'>anchor</a></sup>
122+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L152-L156' title='Snippet source file'>snippet source</a> | <a href='#snippet-queryable_select_many' title='Start of snippet'>anchor</a></sup>
123123
<!-- endSnippet -->
124124

125125
resulting in
@@ -157,7 +157,7 @@ Here is a simple example of grouping words by their first letter.
157157
Queryable<String> words = Queryable.as("Jack", "and", "Jill", "jumped", "up", "the", "hill");
158158
Queryable<Entry<Character, Queryable<String>>> result = words.groupBy(w -> w.toLowerCase().charAt(0));
159159
```
160-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L153-L156' title='Snippet source file'>snippet source</a> | <a href='#snippet-group_by_key' title='Start of snippet'>anchor</a></sup>
160+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L163-L166' title='Snippet source file'>snippet source</a> | <a href='#snippet-group_by_key' title='Start of snippet'>anchor</a></sup>
161161
<!-- endSnippet -->
162162
producing:
163163
<!-- snippet: QueryableTest.testGroupBy.approved.txt -->
@@ -185,7 +185,7 @@ Queryable<String> words = Queryable.as("One Fish Two Fish Red Fish Blue Fish".sp
185185
Queryable<Entry<Object, Object>> result = words.groupBy(w -> w.length(), w -> w.toLowerCase(),
186186
r -> r.join("_"));
187187
```
188-
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L176-L180' title='Snippet source file'>snippet source</a> | <a href='#snippet-group_by_full' title='Start of snippet'>anchor</a></sup>
188+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java#L189-L193' title='Snippet source file'>snippet source</a> | <a href='#snippet-group_by_full' title='Start of snippet'>anchor</a></sup>
189189
<!-- endSnippet -->
190190
resulting in
191191
<!-- snippet: QueryableTest.testGroupByCombineWordsOfSimilarLengths.approved.txt -->

0 commit comments

Comments
 (0)