Skip to content

Commit ebba516

Browse files
algolia-botmillotp
andcommitted
chore: generated code for commit 23a72c3. [skip ci]
Co-authored-by: Pierre Millot <[email protected]>
1 parent 23a72c3 commit ebba516

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2282
-530
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,79 @@
11
package com.algolia.model.recommend;
22

3-
import com.google.gson.annotations.SerializedName;
4-
import java.util.ArrayList;
3+
import com.algolia.utils.CompoundType;
4+
import com.algolia.utils.JSON;
5+
import com.google.gson.TypeAdapter;
6+
import com.google.gson.annotations.JsonAdapter;
7+
import com.google.gson.reflect.TypeToken;
8+
import com.google.gson.stream.JsonReader;
9+
import com.google.gson.stream.JsonWriter;
10+
import java.io.IOException;
511
import java.util.List;
6-
import java.util.Objects;
712

8-
/** Highlighted attributes. */
9-
public class HighlightResult {
13+
@JsonAdapter(HighlightResult.Adapter.class)
14+
/** HighlightResult */
15+
public abstract class HighlightResult implements CompoundType {
1016

11-
@SerializedName("value")
12-
private String value;
13-
14-
@SerializedName("matchLevel")
15-
private MatchLevel matchLevel;
16-
17-
@SerializedName("matchedWords")
18-
private List<String> matchedWords;
19-
20-
@SerializedName("fullyHighlighted")
21-
private Boolean fullyHighlighted;
22-
23-
public HighlightResult setValue(String value) {
24-
this.value = value;
25-
return this;
17+
public static HighlightResult of(HighlightResultOption inside) {
18+
return new HighlightResultHighlightResultOption(inside);
2619
}
2720

28-
/**
29-
* Markup text with occurrences highlighted.
30-
*
31-
* @return value
32-
*/
33-
@javax.annotation.Nullable
34-
public String getValue() {
35-
return value;
21+
public static HighlightResult of(List<HighlightResultOption> inside) {
22+
return new HighlightResultListOfHighlightResultOption(inside);
3623
}
3724

38-
public HighlightResult setMatchLevel(MatchLevel matchLevel) {
39-
this.matchLevel = matchLevel;
40-
return this;
41-
}
25+
public static class Adapter extends TypeAdapter<HighlightResult> {
4226

43-
/**
44-
* Get matchLevel
45-
*
46-
* @return matchLevel
47-
*/
48-
@javax.annotation.Nullable
49-
public MatchLevel getMatchLevel() {
50-
return matchLevel;
51-
}
52-
53-
public HighlightResult setMatchedWords(List<String> matchedWords) {
54-
this.matchedWords = matchedWords;
55-
return this;
56-
}
27+
@Override
28+
public void write(final JsonWriter out, final HighlightResult oneOf) throws IOException {
29+
TypeAdapter runtimeTypeAdapter = (TypeAdapter) JSON.getGson().getAdapter(TypeToken.get(oneOf.getInsideValue().getClass()));
30+
runtimeTypeAdapter.write(out, oneOf.getInsideValue());
31+
}
5732

58-
public HighlightResult addMatchedWords(String matchedWordsItem) {
59-
if (this.matchedWords == null) {
60-
this.matchedWords = new ArrayList<>();
33+
@Override
34+
public HighlightResult read(final JsonReader jsonReader) throws IOException {
35+
HighlightResultOption highlightresultoption = JSON.tryDeserialize(jsonReader, new TypeToken<HighlightResultOption>() {}.getType());
36+
if (highlightresultoption != null) {
37+
return HighlightResult.of(highlightresultoption);
38+
}
39+
List<HighlightResultOption> listofhighlightresultoption = JSON.tryDeserialize(
40+
jsonReader,
41+
new TypeToken<List<HighlightResultOption>>() {}.getType()
42+
);
43+
if (listofhighlightresultoption != null) {
44+
return HighlightResult.of(listofhighlightresultoption);
45+
}
46+
return null;
6147
}
62-
this.matchedWords.add(matchedWordsItem);
63-
return this;
6448
}
49+
}
6550

66-
/**
67-
* List of words from the query that matched the object.
68-
*
69-
* @return matchedWords
70-
*/
71-
@javax.annotation.Nullable
72-
public List<String> getMatchedWords() {
73-
return matchedWords;
74-
}
51+
@JsonAdapter(HighlightResult.Adapter.class)
52+
class HighlightResultHighlightResultOption extends HighlightResult {
7553

76-
public HighlightResult setFullyHighlighted(Boolean fullyHighlighted) {
77-
this.fullyHighlighted = fullyHighlighted;
78-
return this;
79-
}
54+
private final HighlightResultOption insideValue;
8055

81-
/**
82-
* Whether the entire attribute value is highlighted.
83-
*
84-
* @return fullyHighlighted
85-
*/
86-
@javax.annotation.Nullable
87-
public Boolean getFullyHighlighted() {
88-
return fullyHighlighted;
56+
HighlightResultHighlightResultOption(HighlightResultOption insideValue) {
57+
this.insideValue = insideValue;
8958
}
9059

9160
@Override
92-
public boolean equals(Object o) {
93-
if (this == o) {
94-
return true;
95-
}
96-
if (o == null || getClass() != o.getClass()) {
97-
return false;
98-
}
99-
HighlightResult highlightResult = (HighlightResult) o;
100-
return (
101-
Objects.equals(this.value, highlightResult.value) &&
102-
Objects.equals(this.matchLevel, highlightResult.matchLevel) &&
103-
Objects.equals(this.matchedWords, highlightResult.matchedWords) &&
104-
Objects.equals(this.fullyHighlighted, highlightResult.fullyHighlighted)
105-
);
61+
public HighlightResultOption getInsideValue() {
62+
return insideValue;
10663
}
64+
}
10765

108-
@Override
109-
public int hashCode() {
110-
return Objects.hash(value, matchLevel, matchedWords, fullyHighlighted);
111-
}
66+
@JsonAdapter(HighlightResult.Adapter.class)
67+
class HighlightResultListOfHighlightResultOption extends HighlightResult {
11268

113-
@Override
114-
public String toString() {
115-
StringBuilder sb = new StringBuilder();
116-
sb.append("class HighlightResult {\n");
117-
sb.append(" value: ").append(toIndentedString(value)).append("\n");
118-
sb.append(" matchLevel: ").append(toIndentedString(matchLevel)).append("\n");
119-
sb.append(" matchedWords: ").append(toIndentedString(matchedWords)).append("\n");
120-
sb.append(" fullyHighlighted: ").append(toIndentedString(fullyHighlighted)).append("\n");
121-
sb.append("}");
122-
return sb.toString();
69+
private final List<HighlightResultOption> insideValue;
70+
71+
HighlightResultListOfHighlightResultOption(List<HighlightResultOption> insideValue) {
72+
this.insideValue = insideValue;
12373
}
12474

125-
/**
126-
* Convert the given object to string with each line indented by 4 spaces (except the first line).
127-
*/
128-
private String toIndentedString(Object o) {
129-
if (o == null) {
130-
return "null";
131-
}
132-
return o.toString().replace("\n", "\n ");
75+
@Override
76+
public List<HighlightResultOption> getInsideValue() {
77+
return insideValue;
13378
}
13479
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.algolia.model.recommend;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import java.util.List;
5+
import java.util.Objects;
6+
7+
/** Show highlighted section and words matched on a query. */
8+
public class HighlightResultOption {
9+
10+
@SerializedName("value")
11+
private String value;
12+
13+
@SerializedName("matchLevel")
14+
private MatchLevel matchLevel;
15+
16+
@SerializedName("matchedWords")
17+
private List<String> matchedWords;
18+
19+
@SerializedName("fullyHighlighted")
20+
private Boolean fullyHighlighted;
21+
22+
public HighlightResultOption setValue(String value) {
23+
this.value = value;
24+
return this;
25+
}
26+
27+
/**
28+
* Markup text with occurrences highlighted.
29+
*
30+
* @return value
31+
*/
32+
@javax.annotation.Nonnull
33+
public String getValue() {
34+
return value;
35+
}
36+
37+
public HighlightResultOption setMatchLevel(MatchLevel matchLevel) {
38+
this.matchLevel = matchLevel;
39+
return this;
40+
}
41+
42+
/**
43+
* Get matchLevel
44+
*
45+
* @return matchLevel
46+
*/
47+
@javax.annotation.Nonnull
48+
public MatchLevel getMatchLevel() {
49+
return matchLevel;
50+
}
51+
52+
public HighlightResultOption setMatchedWords(List<String> matchedWords) {
53+
this.matchedWords = matchedWords;
54+
return this;
55+
}
56+
57+
public HighlightResultOption addMatchedWords(String matchedWordsItem) {
58+
this.matchedWords.add(matchedWordsItem);
59+
return this;
60+
}
61+
62+
/**
63+
* List of words from the query that matched the object.
64+
*
65+
* @return matchedWords
66+
*/
67+
@javax.annotation.Nonnull
68+
public List<String> getMatchedWords() {
69+
return matchedWords;
70+
}
71+
72+
public HighlightResultOption setFullyHighlighted(Boolean fullyHighlighted) {
73+
this.fullyHighlighted = fullyHighlighted;
74+
return this;
75+
}
76+
77+
/**
78+
* Whether the entire attribute value is highlighted.
79+
*
80+
* @return fullyHighlighted
81+
*/
82+
@javax.annotation.Nullable
83+
public Boolean getFullyHighlighted() {
84+
return fullyHighlighted;
85+
}
86+
87+
@Override
88+
public boolean equals(Object o) {
89+
if (this == o) {
90+
return true;
91+
}
92+
if (o == null || getClass() != o.getClass()) {
93+
return false;
94+
}
95+
HighlightResultOption highlightResultOption = (HighlightResultOption) o;
96+
return (
97+
Objects.equals(this.value, highlightResultOption.value) &&
98+
Objects.equals(this.matchLevel, highlightResultOption.matchLevel) &&
99+
Objects.equals(this.matchedWords, highlightResultOption.matchedWords) &&
100+
Objects.equals(this.fullyHighlighted, highlightResultOption.fullyHighlighted)
101+
);
102+
}
103+
104+
@Override
105+
public int hashCode() {
106+
return Objects.hash(value, matchLevel, matchedWords, fullyHighlighted);
107+
}
108+
109+
@Override
110+
public String toString() {
111+
StringBuilder sb = new StringBuilder();
112+
sb.append("class HighlightResultOption {\n");
113+
sb.append(" value: ").append(toIndentedString(value)).append("\n");
114+
sb.append(" matchLevel: ").append(toIndentedString(matchLevel)).append("\n");
115+
sb.append(" matchedWords: ").append(toIndentedString(matchedWords)).append("\n");
116+
sb.append(" fullyHighlighted: ").append(toIndentedString(fullyHighlighted)).append("\n");
117+
sb.append("}");
118+
return sb.toString();
119+
}
120+
121+
/**
122+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
123+
*/
124+
private String toIndentedString(Object o) {
125+
if (o == null) {
126+
return "null";
127+
}
128+
return o.toString().replace("\n", "\n ");
129+
}
130+
}

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/model/recommend/RecommendHit.java

+26-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.gson.annotations.SerializedName;
44
import java.util.HashMap;
5+
import java.util.Map;
56
import java.util.Objects;
67

78
/** A Recommend hit. */
@@ -11,10 +12,10 @@ public class RecommendHit extends HashMap<String, Object> {
1112
private String objectID;
1213

1314
@SerializedName("_highlightResult")
14-
private HighlightResult highlightResult;
15+
private Map<String, HighlightResult> highlightResult;
1516

1617
@SerializedName("_snippetResult")
17-
private SnippetResult snippetResult;
18+
private Map<String, SnippetResult> snippetResult;
1819

1920
@SerializedName("_rankingInfo")
2021
private RankingInfo rankingInfo;
@@ -40,33 +41,50 @@ public String getObjectID() {
4041
return objectID;
4142
}
4243

43-
public RecommendHit setHighlightResult(HighlightResult highlightResult) {
44+
public RecommendHit setHighlightResult(Map<String, HighlightResult> highlightResult) {
4445
this.highlightResult = highlightResult;
4546
return this;
4647
}
4748

49+
public RecommendHit putHighlightResult(String key, HighlightResult highlightResultItem) {
50+
if (this.highlightResult == null) {
51+
this.highlightResult = new HashMap<>();
52+
}
53+
this.highlightResult.put(key, highlightResultItem);
54+
return this;
55+
}
56+
4857
/**
49-
* Get highlightResult
58+
* Show highlighted section and words matched on a query.
5059
*
5160
* @return highlightResult
5261
*/
5362
@javax.annotation.Nullable
54-
public HighlightResult getHighlightResult() {
63+
public Map<String, HighlightResult> getHighlightResult() {
5564
return highlightResult;
5665
}
5766

58-
public RecommendHit setSnippetResult(SnippetResult snippetResult) {
67+
public RecommendHit setSnippetResult(Map<String, SnippetResult> snippetResult) {
5968
this.snippetResult = snippetResult;
6069
return this;
6170
}
6271

72+
public RecommendHit putSnippetResult(String key, SnippetResult snippetResultItem) {
73+
if (this.snippetResult == null) {
74+
this.snippetResult = new HashMap<>();
75+
}
76+
this.snippetResult.put(key, snippetResultItem);
77+
return this;
78+
}
79+
6380
/**
64-
* Get snippetResult
81+
* Snippeted attributes show parts of the matched attributes. Only returned when
82+
* attributesToSnippet is non-empty.
6583
*
6684
* @return snippetResult
6785
*/
6886
@javax.annotation.Nullable
69-
public SnippetResult getSnippetResult() {
87+
public Map<String, SnippetResult> getSnippetResult() {
7088
return snippetResult;
7189
}
7290

0 commit comments

Comments
 (0)