| 1 | |
package org.codeforamerica.open311.facade.data; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.Date; |
| 5 | |
import java.util.List; |
| 6 | |
|
| 7 | |
import org.codeforamerica.open311.facade.EndpointType; |
| 8 | |
import org.codeforamerica.open311.facade.Format; |
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
public class Endpoint implements Serializable { |
| 16 | |
private static final long serialVersionUID = -5512681512770606630L; |
| 17 | |
private String specificationUrl; |
| 18 | |
private String url; |
| 19 | |
private Date changeset; |
| 20 | |
private EndpointType type; |
| 21 | |
private List<Format> formats; |
| 22 | |
|
| 23 | |
public Endpoint(String specificationUrl, String url, Date changeset, |
| 24 | |
EndpointType type, List<Format> formats) { |
| 25 | 24 | super(); |
| 26 | 24 | this.specificationUrl = specificationUrl; |
| 27 | 24 | this.url = url; |
| 28 | 24 | this.changeset = changeset; |
| 29 | 24 | this.type = type; |
| 30 | 24 | this.formats = formats; |
| 31 | 24 | } |
| 32 | |
|
| 33 | |
public String getSpecificationUrl() { |
| 34 | 7 | return specificationUrl; |
| 35 | |
} |
| 36 | |
|
| 37 | |
public String getUrl() { |
| 38 | 13 | return url; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public Date getChangeset() { |
| 42 | 1 | return changeset; |
| 43 | |
} |
| 44 | |
|
| 45 | |
public EndpointType getType() { |
| 46 | 25 | return type; |
| 47 | |
} |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
public Format getBestFormat() { |
| 55 | 1 | if (formats.contains(Format.JSON)) { |
| 56 | 0 | return Format.JSON; |
| 57 | |
} |
| 58 | 1 | if (formats.contains(Format.XML)) { |
| 59 | 1 | return Format.XML; |
| 60 | |
} |
| 61 | 0 | return null; |
| 62 | |
} |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
public boolean isCompatibleWithFormat(Format format) { |
| 73 | 6 | return formats.contains(format); |
| 74 | |
} |
| 75 | |
} |