Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit 4937cbd

Browse files
chore: fix formatting
1 parent 770015b commit 4937cbd

File tree

3 files changed

+14
-29
lines changed

3 files changed

+14
-29
lines changed

jpyinterpreter/src/main/java/ai/timefold/jpyinterpreter/types/PythonByteArray.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ public static PythonByteArray fromIntTuple(PythonLikeTuple tuple) {
339339
}
340340

341341
public final PythonLikeTuple asIntTuple() {
342-
return IntStream.range(0, valueBuffer.limit()).mapToObj(index -> PythonBytes.BYTE_TO_INT[Byte.toUnsignedInt(valueBuffer.get(index))])
342+
return IntStream.range(0, valueBuffer.limit())
343+
.mapToObj(index -> PythonBytes.BYTE_TO_INT[Byte.toUnsignedInt(valueBuffer.get(index))])
343344
.collect(Collectors.toCollection(PythonLikeTuple::new));
344345
}
345346

@@ -1829,7 +1830,7 @@ public PythonByteArray capitalize() {
18291830
return asString.asAsciiByteArray();
18301831
}
18311832
var tail = PythonString.valueOf(asString.value.substring(1))
1832-
.withModifiedCodepoints(cp -> cp < 128? Character.toLowerCase(cp) : cp).value;
1833+
.withModifiedCodepoints(cp -> cp < 128 ? Character.toLowerCase(cp) : cp).value;
18331834
var head = asString.value.charAt(0);
18341835
if (head < 128) {
18351836
head = Character.toTitleCase(head);
@@ -1885,8 +1886,7 @@ public PythonBoolean isUpper() {
18851886

18861887
public PythonByteArray lower() {
18871888
return asAsciiString().withModifiedCodepoints(
1888-
cp -> cp < 128? Character.toLowerCase(cp) : cp
1889-
).asAsciiByteArray();
1889+
cp -> cp < 128 ? Character.toLowerCase(cp) : cp).asAsciiByteArray();
18901890
}
18911891

18921892
public PythonLikeList<PythonByteArray> splitLines() {
@@ -1905,13 +1905,7 @@ public PythonLikeList<PythonByteArray> splitLines(PythonBoolean keepEnds) {
19051905

19061906
public PythonByteArray swapCase() {
19071907
return asAsciiString().withModifiedCodepoints(
1908-
cp -> {
1909-
if (cp >= 128) {
1910-
return cp;
1911-
}
1912-
return PythonString.CharacterCase.swapCase(cp);
1913-
}
1914-
).asAsciiByteArray();
1908+
cp -> cp < 128 ? PythonString.CharacterCase.swapCase(cp) : cp).asAsciiByteArray();
19151909
}
19161910

19171911
public PythonByteArray title() {
@@ -1920,8 +1914,7 @@ public PythonByteArray title() {
19201914

19211915
public PythonByteArray upper() {
19221916
return asAsciiString().withModifiedCodepoints(
1923-
cp -> cp < 128? Character.toUpperCase(cp) : cp
1924-
).asAsciiByteArray();
1917+
cp -> cp < 128 ? Character.toUpperCase(cp) : cp).asAsciiByteArray();
19251918
}
19261919

19271920
public PythonByteArray zfill(PythonInteger width) {

jpyinterpreter/src/main/java/ai/timefold/jpyinterpreter/types/PythonBytes.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ public PythonBytes capitalize() {
16021602
return this;
16031603
}
16041604
var tail = PythonString.valueOf(asString.value.substring(1))
1605-
.withModifiedCodepoints(cp -> cp < 128? Character.toLowerCase(cp) : cp).value;
1605+
.withModifiedCodepoints(cp -> cp < 128 ? Character.toLowerCase(cp) : cp).value;
16061606
var head = asString.value.charAt(0);
16071607
if (head < 128) {
16081608
head = Character.toTitleCase(head);
@@ -1657,8 +1657,7 @@ public PythonBoolean isUpper() {
16571657

16581658
public PythonBytes lower() {
16591659
return asAsciiString().withModifiedCodepoints(
1660-
cp -> cp < 128? Character.toLowerCase(cp) : cp
1661-
).asAsciiBytes();
1660+
cp -> cp < 128 ? Character.toLowerCase(cp) : cp).asAsciiBytes();
16621661
}
16631662

16641663
public PythonLikeList<PythonBytes> splitLines() {
@@ -1677,13 +1676,7 @@ public PythonLikeList<PythonBytes> splitLines(PythonBoolean keepEnds) {
16771676

16781677
public PythonBytes swapCase() {
16791678
return asAsciiString().withModifiedCodepoints(
1680-
cp -> {
1681-
if (cp >= 128) {
1682-
return cp;
1683-
}
1684-
return PythonString.CharacterCase.swapCase(cp);
1685-
}
1686-
).asAsciiBytes();
1679+
cp -> cp < 128 ? PythonString.CharacterCase.swapCase(cp) : cp).asAsciiBytes();
16871680
}
16881681

16891682
public PythonBytes title() {
@@ -1692,8 +1685,7 @@ public PythonBytes title() {
16921685

16931686
public PythonBytes upper() {
16941687
return asAsciiString().withModifiedCodepoints(
1695-
cp -> cp < 128? Character.toUpperCase(cp) : cp
1696-
).asAsciiBytes();
1688+
cp -> cp < 128 ? Character.toUpperCase(cp) : cp).asAsciiBytes();
16971689
}
16981690

16991691
public PythonBytes zfill(PythonInteger width) {

jpyinterpreter/src/test/java/ai/timefold/jpyinterpreter/types/PythonStringTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package ai.timefold.jpyinterpreter.types;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.assertj.core.api.Assertions.assertThat;
64
import static org.junit.jupiter.api.Assertions.*;
75

6+
import org.junit.jupiter.api.Test;
7+
88
class PythonStringTest {
99

1010
// Other methods are tested in test_str.py
@@ -14,7 +14,7 @@ class PythonStringTest {
1414
@Test
1515
void asAsciiBytes() {
1616
var simple = PythonString.valueOf("abc");
17-
assertThat(simple.asAsciiBytes().asByteArray()).isEqualTo(new byte[] { 'a', 'b', 'c'});
17+
assertThat(simple.asAsciiBytes().asByteArray()).isEqualTo(new byte[] { 'a', 'b', 'c' });
1818

1919
var unicode = PythonString.valueOf("π");
2020
// UTF-16 encoding
@@ -28,7 +28,7 @@ void asAsciiBytes() {
2828
@Test
2929
void asAsciiByteArray() {
3030
var simple = PythonString.valueOf("abc");
31-
assertThat(simple.asAsciiByteArray().asByteArray()).isEqualTo(new byte[] { 'a', 'b', 'c'});
31+
assertThat(simple.asAsciiByteArray().asByteArray()).isEqualTo(new byte[] { 'a', 'b', 'c' });
3232

3333
var unicode = PythonString.valueOf("π");
3434
// UTF-16 encoding

0 commit comments

Comments
 (0)