mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-11 07:52:48 +00:00
immutable Pair, better performant HttpBearerAuth, consistent code-style (#20743)
* make Pair immutable and in google-code-style * apply google-code-style to JavaTimeFormatter (to make it consistent with most other auto-generated java) * move upperCaseBearer to ctor (scheme is final and private; only needs to be fixed once); also replaced Optional with ternary (perf and cleaner code) * apply google-code-style to Authentication to make it consistent with rest of auth code * fresh samples
This commit is contained in:
@@ -22,43 +22,47 @@ import java.time.format.DateTimeParseException;
|
||||
*/
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0-SNAPSHOT")
|
||||
public class JavaTimeFormatter {
|
||||
private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
|
||||
private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||
/**
|
||||
* Get the date format used to parse/format {@code OffsetDateTime} parameters.
|
||||
*
|
||||
* @return DateTimeFormatter
|
||||
*/
|
||||
public DateTimeFormatter getOffsetDateTimeFormatter() {
|
||||
return offsetDateTimeFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the date format used to parse/format {@code OffsetDateTime} parameters.
|
||||
* @return DateTimeFormatter
|
||||
*/
|
||||
public DateTimeFormatter getOffsetDateTimeFormatter() {
|
||||
return offsetDateTimeFormatter;
|
||||
}
|
||||
/**
|
||||
* Set the date format used to parse/format {@code OffsetDateTime} parameters.
|
||||
*
|
||||
* @param offsetDateTimeFormatter {@code DateTimeFormatter}
|
||||
*/
|
||||
public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) {
|
||||
this.offsetDateTimeFormatter = offsetDateTimeFormatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the date format used to parse/format {@code OffsetDateTime} parameters.
|
||||
* @param offsetDateTimeFormatter {@code DateTimeFormatter}
|
||||
*/
|
||||
public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) {
|
||||
this.offsetDateTimeFormatter = offsetDateTimeFormatter;
|
||||
/**
|
||||
* Parse the given string into {@code OffsetDateTime} object.
|
||||
*
|
||||
* @param str String
|
||||
* @return {@code OffsetDateTime}
|
||||
*/
|
||||
public OffsetDateTime parseOffsetDateTime(String str) {
|
||||
try {
|
||||
return OffsetDateTime.parse(str, offsetDateTimeFormatter);
|
||||
} catch (DateTimeParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given string into {@code OffsetDateTime} object.
|
||||
* @param str String
|
||||
* @return {@code OffsetDateTime}
|
||||
*/
|
||||
public OffsetDateTime parseOffsetDateTime(String str) {
|
||||
try {
|
||||
return OffsetDateTime.parse(str, offsetDateTimeFormatter);
|
||||
} catch (DateTimeParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Format the given {@code OffsetDateTime} object into string.
|
||||
* @param offsetDateTime {@code OffsetDateTime}
|
||||
* @return {@code OffsetDateTime} in string format
|
||||
*/
|
||||
public String formatOffsetDateTime(OffsetDateTime offsetDateTime) {
|
||||
return offsetDateTimeFormatter.format(offsetDateTime);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Format the given {@code OffsetDateTime} object into string.
|
||||
*
|
||||
* @param offsetDateTime {@code OffsetDateTime}
|
||||
* @return {@code OffsetDateTime} in string format
|
||||
*/
|
||||
public String formatOffsetDateTime(OffsetDateTime offsetDateTime) {
|
||||
return offsetDateTimeFormatter.format(offsetDateTime);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user