Skip to content

Commit c3e438f

Browse files
committed
Add all required file (pruned later)
1 parent 28e8135 commit c3e438f

File tree

5 files changed

+279
-4
lines changed

5 files changed

+279
-4
lines changed

datamodel/openapi/openapi-core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@
6868
<groupId>com.fasterxml.jackson.core</groupId>
6969
<artifactId>jackson-core</artifactId>
7070
</dependency>
71-
<dependency>
72-
<groupId>org.apache.httpcomponents.core5</groupId>
73-
<artifactId>httpcore5</artifactId>
74-
</dependency>
7571
<!-- scope "provided" -->
7672
<dependency>
7773
<groupId>org.projectlombok</groupId>
@@ -104,6 +100,10 @@
104100
<artifactId>httpcore5</artifactId>
105101
<scope>test</scope>
106102
</dependency>
103+
<dependency>
104+
<groupId>org.apache.httpcomponents.core5</groupId>
105+
<artifactId>httpcore5</artifactId>
106+
</dependency>
107107
</dependencies>
108108
<build>
109109
<plugins>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Prompt Registry API
3+
* Prompt Storage service for Design time & Runtime prompt templates.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
package com.sap.cloud.sdk.services.openapi.apache;
14+
15+
import com.fasterxml.jackson.databind.util.StdDateFormat;
16+
17+
import java.text.DateFormat;
18+
import java.text.DecimalFormat;
19+
import java.text.FieldPosition;
20+
import java.text.ParsePosition;
21+
import java.util.Date;
22+
import java.util.GregorianCalendar;
23+
import java.util.TimeZone;
24+
25+
public class RFC3339DateFormat extends DateFormat {
26+
private static final long serialVersionUID = 1L;
27+
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
28+
29+
private final StdDateFormat fmt = new StdDateFormat()
30+
.withTimeZone(TIMEZONE_Z)
31+
.withColonInTimeZone(true);
32+
33+
public RFC3339DateFormat() {
34+
this.calendar = new GregorianCalendar();
35+
this.numberFormat = new DecimalFormat();
36+
}
37+
38+
@Override
39+
public Date parse(String source) {
40+
return parse(source, new ParsePosition(0));
41+
}
42+
43+
@Override
44+
public Date parse(String source, ParsePosition pos) {
45+
return fmt.parse(source, pos);
46+
}
47+
48+
@Override
49+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
50+
return fmt.format(date, toAppendTo, fieldPosition);
51+
}
52+
53+
@Override
54+
public Object clone() {
55+
return super.clone();
56+
}
57+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Prompt Registry API
3+
* Prompt Storage service for Design time & Runtime prompt templates.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
package com.sap.cloud.sdk.services.openapi.apache;
14+
15+
import com.fasterxml.jackson.core.JsonParser;
16+
import com.fasterxml.jackson.databind.DeserializationContext;
17+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
18+
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
19+
20+
import java.io.IOException;
21+
import java.time.Instant;
22+
import java.time.OffsetDateTime;
23+
import java.time.ZoneId;
24+
import java.time.ZonedDateTime;
25+
import java.time.format.DateTimeFormatter;
26+
import java.time.temporal.Temporal;
27+
import java.time.temporal.TemporalAccessor;
28+
import java.util.function.BiFunction;
29+
import java.util.function.Function;
30+
31+
public class RFC3339InstantDeserializer<T extends Temporal> extends InstantDeserializer<T> {
32+
private static final long serialVersionUID = 1L;
33+
private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault();
34+
private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
35+
= JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault();
36+
37+
public static final RFC3339InstantDeserializer<Instant> INSTANT = new RFC3339InstantDeserializer<>(
38+
Instant.class, DateTimeFormatter.ISO_INSTANT,
39+
Instant::from,
40+
a -> Instant.ofEpochMilli( a.value ),
41+
a -> Instant.ofEpochSecond( a.integer, a.fraction ),
42+
null,
43+
true, // yes, replace zero offset with Z
44+
DEFAULT_NORMALIZE_ZONE_ID,
45+
DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
46+
);
47+
48+
public static final RFC3339InstantDeserializer<OffsetDateTime> OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>(
49+
OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
50+
OffsetDateTime::from,
51+
a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ),
52+
a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ),
53+
(d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( OffsetDateTime.MAX ) ?
54+
d :
55+
d.withOffsetSameInstant( z.getRules().getOffset( d.toLocalDateTime() ) ) ),
56+
true, // yes, replace zero offset with Z
57+
DEFAULT_NORMALIZE_ZONE_ID,
58+
DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
59+
);
60+
61+
public static final RFC3339InstantDeserializer<ZonedDateTime> ZONED_DATE_TIME = new RFC3339InstantDeserializer<>(
62+
ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
63+
ZonedDateTime::from,
64+
a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), a.zoneId ),
65+
a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, a.fraction ), a.zoneId ),
66+
ZonedDateTime::withZoneSameInstant,
67+
false, // keep zero offset and Z separate since zones explicitly supported
68+
DEFAULT_NORMALIZE_ZONE_ID,
69+
DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
70+
);
71+
72+
protected RFC3339InstantDeserializer(
73+
Class<T> supportedType,
74+
DateTimeFormatter formatter,
75+
Function<TemporalAccessor, T> parsedToValue,
76+
Function<FromIntegerArguments, T> fromMilliseconds,
77+
Function<FromDecimalArguments, T> fromNanoseconds,
78+
BiFunction<T, ZoneId, T> adjust,
79+
boolean replaceZeroOffsetAsZ,
80+
boolean normalizeZoneId,
81+
boolean readNumericStringsAsTimestamp) {
82+
super(
83+
supportedType,
84+
formatter,
85+
parsedToValue,
86+
fromMilliseconds,
87+
fromNanoseconds,
88+
adjust,
89+
replaceZeroOffsetAsZ,
90+
normalizeZoneId,
91+
readNumericStringsAsTimestamp
92+
);
93+
}
94+
95+
@Override
96+
protected T _fromString(JsonParser p, DeserializationContext ctxt, String string0) throws IOException {
97+
return super._fromString(p, ctxt, string0.replace( ' ', 'T' ));
98+
}
99+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Prompt Registry API
3+
* Prompt Storage service for Design time & Runtime prompt templates.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
package com.sap.cloud.sdk.services.openapi.apache;
14+
15+
import com.fasterxml.jackson.databind.module.SimpleModule;
16+
17+
import java.time.Instant;
18+
import java.time.OffsetDateTime;
19+
import java.time.ZonedDateTime;
20+
21+
public class RFC3339JavaTimeModule extends SimpleModule {
22+
private static final long serialVersionUID = 1L;
23+
24+
public RFC3339JavaTimeModule() {
25+
super("RFC3339JavaTimeModule");
26+
}
27+
28+
@Override
29+
public void setupModule(SetupContext context) {
30+
super.setupModule(context);
31+
32+
addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT);
33+
addDeserializer(OffsetDateTime.class, RFC3339InstantDeserializer.OFFSET_DATE_TIME);
34+
addDeserializer(ZonedDateTime.class, RFC3339InstantDeserializer.ZONED_DATE_TIME);
35+
}
36+
37+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Prompt Registry API
3+
* Prompt Storage service for Design time & Runtime prompt templates.
4+
*
5+
* The version of the OpenAPI document: 0.0.1
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package com.sap.cloud.sdk.services.openapi.apache;
15+
16+
import java.util.Collection;
17+
import java.util.Iterator;
18+
19+
public class StringUtil {
20+
/**
21+
* Check if the given array contains the given value (with case-insensitive comparison).
22+
*
23+
* @param array The array
24+
* @param value The value to search
25+
* @return true if the array contains the value
26+
*/
27+
public static boolean containsIgnoreCase(String[] array, String value) {
28+
for (String str : array) {
29+
if (value == null && str == null) {
30+
return true;
31+
}
32+
if (value != null && value.equalsIgnoreCase(str)) {
33+
return true;
34+
}
35+
}
36+
return false;
37+
}
38+
39+
/**
40+
* Join an array of strings with the given separator.
41+
* <p>
42+
* Note: This might be replaced by utility method from commons-lang or guava someday
43+
* if one of those libraries is added as dependency.
44+
* </p>
45+
*
46+
* @param array The array of strings
47+
* @param separator The separator
48+
* @return the resulting string
49+
*/
50+
public static String join(String[] array, String separator) {
51+
int len = array.length;
52+
if (len == 0) {
53+
return "";
54+
}
55+
56+
StringBuilder out = new StringBuilder();
57+
out.append(array[0]);
58+
for (int i = 1; i < len; i++) {
59+
out.append(separator).append(array[i]);
60+
}
61+
return out.toString();
62+
}
63+
64+
/**
65+
* Join a list of strings with the given separator.
66+
*
67+
* @param list The list of strings
68+
* @param separator The separator
69+
* @return the resulting string
70+
*/
71+
public static String join(Collection<String> list, String separator) {
72+
Iterator<String> iterator = list.iterator();
73+
StringBuilder out = new StringBuilder();
74+
if (iterator.hasNext()) {
75+
out.append(iterator.next());
76+
}
77+
while (iterator.hasNext()) {
78+
out.append(separator).append(iterator.next());
79+
}
80+
return out.toString();
81+
}
82+
}

0 commit comments

Comments
 (0)