This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02c5d4f
commit 9418c83
Showing
16 changed files
with
275 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
# SortObject | ||
|
||
|
||
## Properties | ||
|
||
| Name | Type | Description | Notes | | ||
|------------ | ------------- | ------------- | -------------| | ||
|**empty** | **Boolean** | | [optional] | | ||
|**sorted** | **Boolean** | | [optional] | | ||
|**unsorted** | **Boolean** | | [optional] | | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
242 changes: 242 additions & 0 deletions
242
...ation-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/SortObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,242 @@ | ||
/* | ||
* Parodos Notification Service API | ||
* This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. | ||
* | ||
* The version of the OpenAPI document: v1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
package com.redhat.parodos.notification.sdk.model; | ||
|
||
import java.io.IOException; | ||
import java.util.HashSet; | ||
import java.util.Map.Entry; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.TypeAdapterFactory; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.google.gson.reflect.TypeToken; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonWriter; | ||
import com.redhat.parodos.notification.sdk.api.JSON; | ||
|
||
/** | ||
* SortObject | ||
*/ | ||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") | ||
public class SortObject { | ||
|
||
public static final String SERIALIZED_NAME_EMPTY = "empty"; | ||
|
||
@SerializedName(SERIALIZED_NAME_EMPTY) | ||
private Boolean empty; | ||
|
||
public static final String SERIALIZED_NAME_SORTED = "sorted"; | ||
|
||
@SerializedName(SERIALIZED_NAME_SORTED) | ||
private Boolean sorted; | ||
|
||
public static final String SERIALIZED_NAME_UNSORTED = "unsorted"; | ||
|
||
@SerializedName(SERIALIZED_NAME_UNSORTED) | ||
private Boolean unsorted; | ||
|
||
public SortObject() { | ||
} | ||
|
||
public SortObject empty(Boolean empty) { | ||
|
||
this.empty = empty; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get empty | ||
* @return empty | ||
**/ | ||
@javax.annotation.Nullable | ||
public Boolean getEmpty() { | ||
return empty; | ||
} | ||
|
||
public void setEmpty(Boolean empty) { | ||
this.empty = empty; | ||
} | ||
|
||
public SortObject sorted(Boolean sorted) { | ||
|
||
this.sorted = sorted; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get sorted | ||
* @return sorted | ||
**/ | ||
@javax.annotation.Nullable | ||
public Boolean getSorted() { | ||
return sorted; | ||
} | ||
|
||
public void setSorted(Boolean sorted) { | ||
this.sorted = sorted; | ||
} | ||
|
||
public SortObject unsorted(Boolean unsorted) { | ||
|
||
this.unsorted = unsorted; | ||
return this; | ||
} | ||
|
||
/** | ||
* Get unsorted | ||
* @return unsorted | ||
**/ | ||
@javax.annotation.Nullable | ||
public Boolean getUnsorted() { | ||
return unsorted; | ||
} | ||
|
||
public void setUnsorted(Boolean unsorted) { | ||
this.unsorted = unsorted; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
SortObject sortObject = (SortObject) o; | ||
return Objects.equals(this.empty, sortObject.empty) && Objects.equals(this.sorted, sortObject.sorted) | ||
&& Objects.equals(this.unsorted, sortObject.unsorted); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(empty, sorted, unsorted); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("class SortObject {\n"); | ||
sb.append(" empty: ").append(toIndentedString(empty)).append("\n"); | ||
sb.append(" sorted: ").append(toIndentedString(sorted)).append("\n"); | ||
sb.append(" unsorted: ").append(toIndentedString(unsorted)).append("\n"); | ||
sb.append("}"); | ||
return sb.toString(); | ||
} | ||
|
||
/** | ||
* Convert the given object to string with each line indented by 4 spaces (except the | ||
* first line). | ||
*/ | ||
private String toIndentedString(Object o) { | ||
if (o == null) { | ||
return "null"; | ||
} | ||
return o.toString().replace("\n", "\n "); | ||
} | ||
|
||
public static HashSet<String> openapiFields; | ||
|
||
public static HashSet<String> openapiRequiredFields; | ||
|
||
static { | ||
// a set of all properties/fields (JSON key names) | ||
openapiFields = new HashSet<String>(); | ||
openapiFields.add("empty"); | ||
openapiFields.add("sorted"); | ||
openapiFields.add("unsorted"); | ||
|
||
// a set of required properties/fields (JSON key names) | ||
openapiRequiredFields = new HashSet<String>(); | ||
} | ||
|
||
/** | ||
* Validates the JSON Object and throws an exception if issues found | ||
* @param jsonObj JSON Object | ||
* @throws IOException if the JSON Object is invalid with respect to SortObject | ||
*/ | ||
public static void validateJsonObject(JsonObject jsonObj) throws IOException { | ||
if (jsonObj == null) { | ||
if (!SortObject.openapiRequiredFields.isEmpty()) { // has required fields but | ||
// JSON object is null | ||
throw new IllegalArgumentException( | ||
String.format("The required field(s) %s in SortObject is not found in the empty JSON string", | ||
SortObject.openapiRequiredFields.toString())); | ||
} | ||
} | ||
|
||
Set<Entry<String, JsonElement>> entries = jsonObj.entrySet(); | ||
// check to see if the JSON string contains additional fields | ||
for (Entry<String, JsonElement> entry : entries) { | ||
if (!SortObject.openapiFields.contains(entry.getKey())) { | ||
throw new IllegalArgumentException(String.format( | ||
"The field `%s` in the JSON string is not defined in the `SortObject` properties. JSON: %s", | ||
entry.getKey(), jsonObj.toString())); | ||
} | ||
} | ||
} | ||
|
||
public static class CustomTypeAdapterFactory implements TypeAdapterFactory { | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { | ||
if (!SortObject.class.isAssignableFrom(type.getRawType())) { | ||
return null; // this class only serializes 'SortObject' and its subtypes | ||
} | ||
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class); | ||
final TypeAdapter<SortObject> thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(SortObject.class)); | ||
|
||
return (TypeAdapter<T>) new TypeAdapter<SortObject>() { | ||
@Override | ||
public void write(JsonWriter out, SortObject value) throws IOException { | ||
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); | ||
elementAdapter.write(out, obj); | ||
} | ||
|
||
@Override | ||
public SortObject read(JsonReader in) throws IOException { | ||
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); | ||
validateJsonObject(jsonObj); | ||
return thisAdapter.fromJsonTree(jsonObj); | ||
} | ||
|
||
}.nullSafe(); | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Create an instance of SortObject given an JSON string | ||
* @param jsonString JSON string | ||
* @return An instance of SortObject | ||
* @throws IOException if the JSON string is invalid with respect to SortObject | ||
*/ | ||
public static SortObject fromJson(String jsonString) throws IOException { | ||
return JSON.getGson().fromJson(jsonString, SortObject.class); | ||
} | ||
|
||
/** | ||
* Convert an instance of SortObject to an JSON string | ||
* @return JSON string | ||
*/ | ||
public String toJson() { | ||
return JSON.getGson().toJson(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.