Skip to content

Commit 291cd13

Browse files
committedMar 6, 2025·
convert to 4 spaces
1 parent 3fffcda commit 291cd13

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed
 

‎README.md

+60-60
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,26 @@ To read a text file in UTF-8:
7070

7171
```java
7272
String text = new TextOf(
73-
new File("/code/a.txt")
73+
new File("/code/a.txt")
7474
).asString();
7575
```
7676

7777
To write a text into a file:
7878

7979
```java
8080
new LengthOf(
81-
new TeeInput(
82-
"Hello, world!",
83-
new File("/code/a.txt")
84-
)
81+
new TeeInput(
82+
"Hello, world!",
83+
new File("/code/a.txt")
84+
)
8585
).value();
8686
```
8787

8888
To read a binary file from classpath:
8989

9090
```java
9191
byte[] data = new BytesOf(
92-
new ResourceOf("foo/img.jpg")
92+
new ResourceOf("foo/img.jpg")
9393
).asBytes();
9494
```
9595

@@ -99,8 +99,8 @@ To format a text:
9999

100100
```java
101101
String text = new FormattedText(
102-
"How are you, %s?",
103-
name
102+
"How are you, %s?",
103+
name
104104
).asString();
105105
```
106106

@@ -109,11 +109,11 @@ To manipulate with a text:
109109
```java
110110
// To lower case
111111
new Lowered(
112-
new TextOf("Hello")
112+
new TextOf("Hello")
113113
);
114114
// To upper case
115115
new Upper(
116-
new TextOf("Hello")
116+
new TextOf("Hello")
117117
);
118118
```
119119

@@ -125,53 +125,53 @@ To filter a collection:
125125

126126
```java
127127
Collection<String> filtered = new ListOf<>(
128-
new Filtered<>(
129-
s -> s.length() > 4,
130-
new IterableOf<>("hello", "world", "dude")
131-
)
128+
new Filtered<>(
129+
s -> s.length() > 4,
130+
new IterableOf<>("hello", "world", "dude")
131+
)
132132
);
133133
```
134134

135135
To flatten one iterable:
136136
```java
137137
new Joined<>(
138-
new Mapped<IterableOf>(
139-
iter -> new IterableOf<>(
140-
new ListOf<>(iter).toArray(new Integer[]{})
141-
),
142-
new IterableOf<>(1, 2, 3, 4, 5, 6)
143-
)
138+
new Mapped<IterableOf>(
139+
iter -> new IterableOf<>(
140+
new ListOf<>(iter).toArray(new Integer[]{})
141+
),
142+
new IterableOf<>(1, 2, 3, 4, 5, 6)
143+
)
144144
); // Iterable<Integer>
145145
```
146146

147147
To flatten and join several iterables:
148148
```java
149149
new Joined<>(
150-
new Mapped<IterableOf>(
151-
iter -> new IterableOf<>(
152-
new Joined<>(iter)
153-
),
154-
new Joined<>(
155-
new IterableOf<>(new IterableOf<>(1, 2, 3)),
156-
new IterableOf<>(new IterableOf<>(4, 5, 6))
150+
new Mapped<IterableOf>(
151+
iter -> new IterableOf<>(
152+
new Joined<>(iter)
153+
),
154+
new Joined<>(
155+
new IterableOf<>(new IterableOf<>(1, 2, 3)),
156+
new IterableOf<>(new IterableOf<>(4, 5, 6))
157+
)
157158
)
158-
)
159159
); // Iterable<Integer>
160160
```
161161

162162
To iterate a collection:
163163

164164
```java
165165
new And(
166-
new Mapped<>(
167-
new FuncOf<>(
168-
input -> {
169-
System.out.printf("Item: %s\n", input);
170-
},
171-
new True()
172-
),
173-
new IterableOf<>("how", "are", "you", "?")
174-
)
166+
new Mapped<>(
167+
new FuncOf<>(
168+
input -> {
169+
System.out.printf("Item: %s\n", input);
170+
},
171+
new True()
172+
),
173+
new IterableOf<>("how", "are", "you", "?")
174+
)
175175
).value();
176176
```
177177

@@ -189,25 +189,25 @@ To sort a list of words in the file:
189189

190190
```java
191191
List<Text> sorted = new ListOf<>(
192-
new Sorted<>(
193-
new Mapped<>(
194-
text -> new ComparableText(text),
195-
new Split(
196-
new TextOf(
197-
new File("/tmp/names.txt")
198-
),
199-
new TextOf("\\s+")
200-
)
192+
new Sorted<>(
193+
new Mapped<>(
194+
text -> new ComparableText(text),
195+
new Split(
196+
new TextOf(
197+
new File("/tmp/names.txt")
198+
),
199+
new TextOf("\\s+")
200+
)
201+
)
201202
)
202-
)
203203
);
204204
```
205205

206206
To count elements in an iterable:
207207

208208
```java
209209
int total = new LengthOf(
210-
new IterableOf<>("how", "are", "you")
210+
new IterableOf<>("how", "are", "you")
211211
).value().intValue();
212212
```
213213

@@ -260,39 +260,39 @@ This is a traditional `foreach` loop:
260260

261261
```java
262262
for (String name : names) {
263-
System.out.printf("Hello, %s!\n", name);
263+
System.out.printf("Hello, %s!\n", name);
264264
}
265265
```
266266

267267
This is its object-oriented alternative (no streams!):
268268

269269
```java
270270
new And(
271-
n -> {
272-
System.out.printf("Hello, %s!\n", n);
273-
return new True().value();
274-
},
275-
names
271+
n -> {
272+
System.out.printf("Hello, %s!\n", n);
273+
return new True().value();
274+
},
275+
names
276276
).value();
277277
```
278278

279279
This is an endless `while/do` loop:
280280

281281
```java
282282
while (!ready) {
283-
System.out.println("Still waiting...");
283+
System.out.println("Still waiting...");
284284
}
285285
```
286286

287287
Here is its object-oriented alternative:
288288

289289
```java
290290
new And(
291-
ready -> {
292-
System.out.println("Still waiting...");
293-
return !ready;
294-
},
295-
new Endless<>(booleanParameter)
291+
ready -> {
292+
System.out.println("Still waiting...");
293+
return !ready;
294+
},
295+
new Endless<>(booleanParameter)
296296
).value();
297297
```
298298

0 commit comments

Comments
 (0)
Please sign in to comment.