Skip to content

Commit ef67c7e

Browse files
chore: generated code for commit 1ceab07.
Co-authored-by: François Chalifour <[email protected]>
1 parent 1ceab07 commit ef67c7e

File tree

20 files changed

+764
-175
lines changed

20 files changed

+764
-175
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// This file is generated, manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation.
3+
4+
package com.algolia.model.predict;
5+
6+
import com.algolia.utils.CompoundType;
7+
import com.fasterxml.jackson.annotation.*;
8+
import com.fasterxml.jackson.core.*;
9+
import com.fasterxml.jackson.core.type.TypeReference;
10+
import com.fasterxml.jackson.databind.*;
11+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
12+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
13+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
14+
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
15+
import java.io.IOException;
16+
17+
/** Affinities */
18+
@JsonDeserialize(using = Affinities.AffinitiesDeserializer.class)
19+
@JsonSerialize(using = Affinities.AffinitiesSerializer.class)
20+
public abstract class Affinities implements CompoundType {
21+
22+
public static Affinities of(AffinitiesSuccess inside) {
23+
return new AffinitiesAffinitiesSuccess(inside);
24+
}
25+
26+
public static Affinities of(Error inside) {
27+
return new AffinitiesError(inside);
28+
}
29+
30+
public static class AffinitiesSerializer extends StdSerializer<Affinities> {
31+
32+
public AffinitiesSerializer(Class<Affinities> t) {
33+
super(t);
34+
}
35+
36+
public AffinitiesSerializer() {
37+
this(null);
38+
}
39+
40+
@Override
41+
public void serialize(Affinities value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
42+
jgen.writeObject(value.getInsideValue());
43+
}
44+
}
45+
46+
public static class AffinitiesDeserializer extends StdDeserializer<Affinities> {
47+
48+
public AffinitiesDeserializer() {
49+
this(Affinities.class);
50+
}
51+
52+
public AffinitiesDeserializer(Class<?> vc) {
53+
super(vc);
54+
}
55+
56+
@Override
57+
public Affinities deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
58+
JsonNode tree = jp.readValueAsTree();
59+
Affinities deserialized = null;
60+
61+
int match = 0;
62+
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
63+
String currentType = "";
64+
// deserialize AffinitiesSuccess
65+
try {
66+
boolean attemptParsing = true;
67+
currentType = "AffinitiesSuccess";
68+
if (
69+
((currentType.equals("Integer") || currentType.equals("Long")) && token == JsonToken.VALUE_NUMBER_INT) |
70+
((currentType.equals("Float") || currentType.equals("Double")) && token == JsonToken.VALUE_NUMBER_FLOAT) |
71+
(currentType.equals("Boolean") && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)) |
72+
(currentType.equals("String") && token == JsonToken.VALUE_STRING) |
73+
(currentType.startsWith("List<") && token == JsonToken.START_ARRAY)
74+
) {
75+
deserialized =
76+
Affinities.of((AffinitiesSuccess) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<AffinitiesSuccess>() {}));
77+
match++;
78+
} else if (token == JsonToken.START_OBJECT) {
79+
try {
80+
deserialized =
81+
Affinities.of((AffinitiesSuccess) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<AffinitiesSuccess>() {}));
82+
match++;
83+
} catch (IOException e) {
84+
// do nothing
85+
}
86+
}
87+
} catch (Exception e) {
88+
// deserialization failed, continue
89+
System.err.println("Failed to deserialize oneOf AffinitiesSuccess (error: " + e.getMessage() + ") (type: " + currentType + ")");
90+
}
91+
92+
// deserialize Error
93+
try {
94+
boolean attemptParsing = true;
95+
currentType = "Error";
96+
if (
97+
((currentType.equals("Integer") || currentType.equals("Long")) && token == JsonToken.VALUE_NUMBER_INT) |
98+
((currentType.equals("Float") || currentType.equals("Double")) && token == JsonToken.VALUE_NUMBER_FLOAT) |
99+
(currentType.equals("Boolean") && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)) |
100+
(currentType.equals("String") && token == JsonToken.VALUE_STRING) |
101+
(currentType.startsWith("List<") && token == JsonToken.START_ARRAY)
102+
) {
103+
deserialized = Affinities.of((Error) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Error>() {}));
104+
match++;
105+
} else if (token == JsonToken.START_OBJECT) {
106+
try {
107+
deserialized = Affinities.of((Error) tree.traverse(jp.getCodec()).readValueAs(new TypeReference<Error>() {}));
108+
match++;
109+
} catch (IOException e) {
110+
// do nothing
111+
}
112+
}
113+
} catch (Exception e) {
114+
// deserialization failed, continue
115+
System.err.println("Failed to deserialize oneOf Error (error: " + e.getMessage() + ") (type: " + currentType + ")");
116+
}
117+
118+
if (match == 1) {
119+
return deserialized;
120+
}
121+
throw new IOException(String.format("Failed deserialization for Affinities: %d classes match result, expected 1", match));
122+
}
123+
124+
/** Handle deserialization of the 'null' value. */
125+
@Override
126+
public Affinities getNullValue(DeserializationContext ctxt) throws JsonMappingException {
127+
throw new JsonMappingException(ctxt.getParser(), "Affinities cannot be null");
128+
}
129+
}
130+
}
131+
132+
class AffinitiesAffinitiesSuccess extends Affinities {
133+
134+
private final AffinitiesSuccess insideValue;
135+
136+
AffinitiesAffinitiesSuccess(AffinitiesSuccess insideValue) {
137+
this.insideValue = insideValue;
138+
}
139+
140+
@Override
141+
public AffinitiesSuccess getInsideValue() {
142+
return insideValue;
143+
}
144+
}
145+
146+
class AffinitiesError extends Affinities {
147+
148+
private final Error insideValue;
149+
150+
AffinitiesError(Error insideValue) {
151+
this.insideValue = insideValue;
152+
}
153+
154+
@Override
155+
public Error getInsideValue() {
156+
return insideValue;
157+
}
158+
}
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
import java.util.Objects;
1010

1111
/** Prediction for the **affinities** model. */
12-
public class PredictionsAffinities {
12+
public class AffinitiesSuccess {
1313

1414
@JsonProperty("value")
1515
private List<Affinity> value = new ArrayList<>();
1616

1717
@JsonProperty("lastUpdatedAt")
1818
private String lastUpdatedAt;
1919

20-
public PredictionsAffinities setValue(List<Affinity> value) {
20+
public AffinitiesSuccess setValue(List<Affinity> value) {
2121
this.value = value;
2222
return this;
2323
}
2424

25-
public PredictionsAffinities addValue(Affinity valueItem) {
25+
public AffinitiesSuccess addValue(Affinity valueItem) {
2626
this.value.add(valueItem);
2727
return this;
2828
}
@@ -37,7 +37,7 @@ public List<Affinity> getValue() {
3737
return value;
3838
}
3939

40-
public PredictionsAffinities setLastUpdatedAt(String lastUpdatedAt) {
40+
public AffinitiesSuccess setLastUpdatedAt(String lastUpdatedAt) {
4141
this.lastUpdatedAt = lastUpdatedAt;
4242
return this;
4343
}
@@ -60,10 +60,8 @@ public boolean equals(Object o) {
6060
if (o == null || getClass() != o.getClass()) {
6161
return false;
6262
}
63-
PredictionsAffinities predictionsAffinities = (PredictionsAffinities) o;
64-
return (
65-
Objects.equals(this.value, predictionsAffinities.value) && Objects.equals(this.lastUpdatedAt, predictionsAffinities.lastUpdatedAt)
66-
);
63+
AffinitiesSuccess affinitiesSuccess = (AffinitiesSuccess) o;
64+
return Objects.equals(this.value, affinitiesSuccess.value) && Objects.equals(this.lastUpdatedAt, affinitiesSuccess.lastUpdatedAt);
6765
}
6866

6967
@Override
@@ -74,7 +72,7 @@ public int hashCode() {
7472
@Override
7573
public String toString() {
7674
StringBuilder sb = new StringBuilder();
77-
sb.append("class PredictionsAffinities {\n");
75+
sb.append("class AffinitiesSuccess {\n");
7876
sb.append(" value: ").append(toIndentedString(value)).append("\n");
7977
sb.append(" lastUpdatedAt: ").append(toIndentedString(lastUpdatedAt)).append("\n");
8078
sb.append("}");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// This file is generated, manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation.
3+
4+
package com.algolia.model.predict;
5+
6+
import com.fasterxml.jackson.annotation.*;
7+
import java.util.Objects;
8+
9+
/** The error when the model is not available. */
10+
public class Error {
11+
12+
@JsonProperty("error")
13+
private String error;
14+
15+
public Error setError(String error) {
16+
this.error = error;
17+
return this;
18+
}
19+
20+
/**
21+
* Get error
22+
*
23+
* @return error
24+
*/
25+
@javax.annotation.Nonnull
26+
public String getError() {
27+
return error;
28+
}
29+
30+
@Override
31+
public boolean equals(Object o) {
32+
if (this == o) {
33+
return true;
34+
}
35+
if (o == null || getClass() != o.getClass()) {
36+
return false;
37+
}
38+
Error error = (Error) o;
39+
return Objects.equals(this.error, error.error);
40+
}
41+
42+
@Override
43+
public int hashCode() {
44+
return Objects.hash(error);
45+
}
46+
47+
@Override
48+
public String toString() {
49+
StringBuilder sb = new StringBuilder();
50+
sb.append("class Error {\n");
51+
sb.append(" error: ").append(toIndentedString(error)).append("\n");
52+
sb.append("}");
53+
return sb.toString();
54+
}
55+
56+
/**
57+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
58+
*/
59+
private String toIndentedString(Object o) {
60+
if (o == null) {
61+
return "null";
62+
}
63+
return o.toString().replace("\n", "\n ");
64+
}
65+
}

0 commit comments

Comments
 (0)