Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ public class AddressRequest extends BasicRequest {
private Map<String, String> toBound;
@JsonProperty("restrict_value")
private Boolean restrictValue;
@JsonProperty("language")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если название поля совпадает с полем в json, то аннотацию @JsonProperty не обязательно ставить

private String language;


public AddressRequest(String query,
Integer count,
List<Map<FilterProperty, String>> locationsBoost,
List<Map<FilterProperty, String>> locations, Map<String, String> fromBound,
Map<String, String> toBound, Boolean restrictValue) {
Map<String, String> toBound, Boolean restrictValue, String language) {
super(query, count);
this.locationsBoost = locationsBoost;
this.locations = locations;
this.fromBound = fromBound;
this.toBound = toBound;
this.restrictValue = restrictValue;
this.language = language;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
private Map<String, String> fromBound = new HashMap<>();
private Map<String, String> toBound = new HashMap<>();
private Boolean restrictValue = false;
private String language;

public static AddressRequestBuilder create(String query) {
return new AddressRequestBuilder(query);
Expand Down Expand Up @@ -43,9 +44,15 @@
return this;
}

public AddressRequestBuilder outputLanguage(String language) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Предлагаю сделать более типизировано: у нас есть конечный список языков, которые поддерживаются – это русский (ru) и английский (en). Можно сделать Enum, например:

public enum Language {
  EN,
  RU
}

А при создании AddressRequest делать такое: language.name().toLower()

this.language = language;
return this;

Check warning on line 49 in src/main/java/com/kuliginstepan/dadata/client/domain/address/AddressRequestBuilder.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/kuliginstepan/dadata/client/domain/address/AddressRequestBuilder.java#L48-L49

Added lines #L48 - L49 were not covered by tests
}


@Override
public AddressRequest build() {
return new AddressRequest(super.query, super.count, super.locationsBoost, locations, fromBound, toBound,
restrictValue);
restrictValue, language);
}
}