|
| 1 | +package com.mindee.parsing.standard; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 5 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 6 | +import com.mindee.geometry.Polygon; |
| 7 | +import com.mindee.geometry.PolygonDeserializer; |
| 8 | +import lombok.Getter; |
| 9 | + |
| 10 | +/** |
| 11 | + * Represent a postal address field broken down into its individual components. |
| 12 | + */ |
| 13 | +@Getter |
| 14 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 15 | +public final class AddressField extends StringField { |
| 16 | + /** The address exactly as it appears on the document. */ |
| 17 | + private final String rawValue; |
| 18 | + |
| 19 | + /** Street number. */ |
| 20 | + private final String streetNumber; |
| 21 | + |
| 22 | + /** Street name. */ |
| 23 | + private final String streetName; |
| 24 | + |
| 25 | + /** PO-box number. */ |
| 26 | + private final String poBox; |
| 27 | + |
| 28 | + /** Additional address complement. */ |
| 29 | + private final String addressComplement; |
| 30 | + |
| 31 | + /** City or locality. */ |
| 32 | + private final String city; |
| 33 | + |
| 34 | + /** Postal or ZIP code. */ |
| 35 | + private final String postalCode; |
| 36 | + |
| 37 | + /** State, province or region. */ |
| 38 | + private final String state; |
| 39 | + |
| 40 | + /** Country. */ |
| 41 | + private final String country; |
| 42 | + |
| 43 | + public AddressField( |
| 44 | + @JsonProperty("value") |
| 45 | + String value, |
| 46 | + @JsonProperty("raw_value") |
| 47 | + String rawValue, |
| 48 | + @JsonProperty("street_number") |
| 49 | + String streetNumber, |
| 50 | + @JsonProperty("street_name") |
| 51 | + String streetName, |
| 52 | + @JsonProperty("po_box") |
| 53 | + String poBox, |
| 54 | + @JsonProperty("address_complement") |
| 55 | + String addressComplement, |
| 56 | + @JsonProperty("city") |
| 57 | + String city, |
| 58 | + @JsonProperty("postal_code") |
| 59 | + String postalCode, |
| 60 | + @JsonProperty("state") |
| 61 | + String state, |
| 62 | + @JsonProperty("country") |
| 63 | + String country, |
| 64 | + @JsonProperty("confidence") |
| 65 | + Double confidence, |
| 66 | + @JsonProperty("polygon") |
| 67 | + @JsonDeserialize(using = PolygonDeserializer.class) |
| 68 | + Polygon polygon, |
| 69 | + @JsonProperty("page_id") |
| 70 | + Integer pageId |
| 71 | + ) { |
| 72 | + super(value, rawValue, confidence, polygon, pageId); |
| 73 | + this.rawValue = rawValue; |
| 74 | + this.streetNumber = streetNumber; |
| 75 | + this.streetName = streetName; |
| 76 | + this.poBox = poBox; |
| 77 | + this.addressComplement = addressComplement; |
| 78 | + this.city = city; |
| 79 | + this.postalCode = postalCode; |
| 80 | + this.state = state; |
| 81 | + this.country = country; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Address field constructor only containing the value. |
| 86 | + */ |
| 87 | + public AddressField( |
| 88 | + String value, |
| 89 | + Double confidence, |
| 90 | + Polygon polygon |
| 91 | + ) { |
| 92 | + this(value, null, null, null, null, |
| 93 | + null, null, null, null, null, |
| 94 | + confidence, polygon, null); |
| 95 | + } |
| 96 | +} |
0 commit comments