Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import lombok.Getter;
- import lombok.Setter;
- import static com.fasterxml.jackson.annotation.JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES;
- @Getter
- @Setter
- @JsonFormat(with = ACCEPT_CASE_INSENSITIVE_PROPERTIES)
- public class ApplicationDefinition {
- private Application application;
- @Getter
- @Setter
- @JsonFormat(with = ACCEPT_CASE_INSENSITIVE_PROPERTIES)
- public static class Application {
- @JsonProperty(required = true)
- private String art;
- @JsonProperty(required = true)
- private String team;
- }
- }
- import com.ebsco.platform.shared.gateway.request.executor.exception.MissingRepositoryOwnerException;
- import com.fasterxml.jackson.core.JsonProcessingException;
- import com.fasterxml.jackson.databind.DeserializationFeature;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Service;
- import javax.annotation.PostConstruct;
- @Slf4j
- @Service
- @RequiredArgsConstructor
- public class GithubService {
- ...
- private final ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory());
- @PostConstruct
- public void init() {
- yamlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- }
- ...
- private ... method(...) {
- try (...) {
- ...
- ApplicationDefinition applicationDefinition = yamlMapper
- .readValue(getApplicationDefinitionFromResponse(response), ApplicationDefinition.class);
- ...
- } catch (JsonProcessingException e) {
- throw new MissingRepositoryOwnerException(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement