Skip to content

Commit e043b09

Browse files
committed
again formatting
1 parent 7611ba0 commit e043b09

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/adapter/ODataGenericConverter.java

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,50 @@
2222
/**
2323
* Generic fluent helper converters for String based OData V4 primitives.
2424
*
25-
* @param <JavaT> The Java type to which conversion happens.
25+
* @param <JavaT>
26+
* The Java type to which conversion happens.
2627
*/
27-
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
28-
final class ODataGenericConverter<JavaT> extends AbstractTypeConverter<JavaT, String> {
28+
@RequiredArgsConstructor( access = AccessLevel.PRIVATE )
29+
final class ODataGenericConverter<JavaT> extends AbstractTypeConverter<JavaT, String>
30+
{
2931
private static final ODataGenericConverter<LocalDate> LOCAL_DATE =
30-
new ODataGenericConverter<>(
31-
LocalDate.class,
32-
o -> o.format(DateTimeFormatter.ISO_LOCAL_DATE),
33-
s -> LocalDate.parse(s, DateTimeFormatter.ISO_LOCAL_DATE));
32+
new ODataGenericConverter<>(
33+
LocalDate.class,
34+
o -> o.format(DateTimeFormatter.ISO_LOCAL_DATE),
35+
s -> LocalDate.parse(s, DateTimeFormatter.ISO_LOCAL_DATE));
3436

3537
private static final ODataGenericConverter<LocalTime> LOCAL_TIME =
36-
new ODataGenericConverter<>(
37-
LocalTime.class,
38-
o -> o.format(DateTimeFormatter.ISO_LOCAL_TIME),
39-
s -> LocalTime.parse(s, DateTimeFormatter.ISO_LOCAL_TIME));
38+
new ODataGenericConverter<>(
39+
LocalTime.class,
40+
o -> o.format(DateTimeFormatter.ISO_LOCAL_TIME),
41+
s -> LocalTime.parse(s, DateTimeFormatter.ISO_LOCAL_TIME));
4042

4143
private static final ODataGenericConverter<OffsetDateTime> OFFSET_DATE_TIME =
42-
new ODataGenericConverter<>(
43-
OffsetDateTime.class,
44-
o -> o.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME),
45-
s -> OffsetDateTime.parse(s, DateTimeFormatter.ISO_OFFSET_DATE_TIME));
44+
new ODataGenericConverter<>(
45+
OffsetDateTime.class,
46+
o -> o.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME),
47+
s -> OffsetDateTime.parse(s, DateTimeFormatter.ISO_OFFSET_DATE_TIME));
4648

4749
private static final ODataGenericConverter<UUID> GUID =
48-
new ODataGenericConverter<>(UUID.class, UUID::toString, UUID::fromString);
50+
new ODataGenericConverter<>(UUID.class, UUID::toString, UUID::fromString);
4951

5052
private static final ODataGenericConverter<Duration> DURATION =
51-
new ODataGenericConverter<>(Duration.class, Duration::toString, Duration::parse);
53+
new ODataGenericConverter<>(Duration.class, Duration::toString, Duration::parse);
5254

5355
private static final ODataGenericConverter<byte[]> BINARY =
54-
new ODataGenericConverter<>(
55-
byte[].class,
56-
Base64.getEncoder()::encodeToString,
57-
ODataGenericConverter::decodeBinary);
56+
new ODataGenericConverter<>(
57+
byte[].class,
58+
Base64.getEncoder()::encodeToString,
59+
ODataGenericConverter::decodeBinary);
5860

5961
private static final ODataGenericConverter<String> STRING =
60-
new ODataGenericConverter<>(String.class, Function.identity(), Function.identity());
62+
new ODataGenericConverter<>(String.class, Function.identity(), Function.identity());
6163

6264
/**
6365
* Array of OData value converters for primitive types.
6466
*/
6567
public static final ODataGenericConverter<?>[] DEFAULT_CONVERTERS =
66-
{LOCAL_DATE, LOCAL_TIME, OFFSET_DATE_TIME, GUID, DURATION, BINARY, STRING};
68+
{ LOCAL_DATE, LOCAL_TIME, OFFSET_DATE_TIME, GUID, DURATION, BINARY, STRING };
6769

6870
@Getter
6971
private final Class<JavaT> type;
@@ -75,13 +77,14 @@ final class ODataGenericConverter<JavaT> extends AbstractTypeConverter<JavaT, St
7577
private final Function<String, JavaT> deserializer;
7678

7779
@Nonnull
78-
private static byte[] decodeBinary(@Nonnull final String value) {
80+
private static byte[] decodeBinary( @Nonnull final String value )
81+
{
7982
final boolean containsBase64Alphabet = value.indexOf('+') >= 0 || value.indexOf('/') >= 0;
8083
final boolean containsBase64UrlAlphabet = value.indexOf('-') >= 0 || value.indexOf('_') >= 0;
8184

82-
if (containsBase64Alphabet && containsBase64UrlAlphabet) {
85+
if( containsBase64Alphabet && containsBase64UrlAlphabet ) {
8386
throw new IllegalArgumentException(
84-
"Invalid binary value: mixed Base64 and Base64URL alphabets are not allowed.");
87+
"Invalid binary value: mixed Base64 and Base64URL alphabets are not allowed.");
8588
}
8689

8790
final Base64.Decoder decoder = containsBase64UrlAlphabet ? Base64.getUrlDecoder() : Base64.getDecoder();
@@ -90,14 +93,16 @@ private static byte[] decodeBinary(@Nonnull final String value) {
9093

9194
@Nonnull
9295
@Override
93-
public ConvertedObject<String> toDomainNonNull(@Nonnull final JavaT object) {
96+
public ConvertedObject<String> toDomainNonNull( @Nonnull final JavaT object )
97+
{
9498
return ConvertedObject.of(serializer.apply(object));
9599
}
96100

97101
@Nonnull
98102
@Override
99-
public ConvertedObject<JavaT> fromDomainNonNull(@Nonnull final String domainObject) {
103+
public ConvertedObject<JavaT> fromDomainNonNull( @Nonnull final String domainObject )
104+
{
100105
final Try<JavaT> maybe = Try.of(() -> deserializer.apply(domainObject));
101106
return maybe.map(ConvertedObject::of).getOrElse(ConvertedObject::ofNotConvertible);
102107
}
103-
}
108+
}

0 commit comments

Comments
 (0)