summaryrefslogtreecommitdiff
path: root/src/main/java/com/p4square/ccbapi/model/Country.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-03-19 02:05:33 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-03-19 02:07:24 -0700
commitb9eb1329a6dbec7b75c21d8e0eb13134121db6bb (patch)
treefec73ab32ff625c304513c24e864809845eede1a /src/main/java/com/p4square/ccbapi/model/Country.java
Initial commit for the CCB API Client.
The client currently supports the following APIs: * individual_profiles * individual_profile_from_id * individual_profile_from_login_password * individual_profile_from_micr * custom_field_labels
Diffstat (limited to 'src/main/java/com/p4square/ccbapi/model/Country.java')
-rw-r--r--src/main/java/com/p4square/ccbapi/model/Country.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/com/p4square/ccbapi/model/Country.java b/src/main/java/com/p4square/ccbapi/model/Country.java
new file mode 100644
index 0000000..e6936a5
--- /dev/null
+++ b/src/main/java/com/p4square/ccbapi/model/Country.java
@@ -0,0 +1,48 @@
+package com.p4square.ccbapi.model;
+
+import javax.xml.bind.annotation.*;
+
+/**
+ * Country code and name pair.
+ */
+@XmlRootElement(name="country")
+@XmlAccessorType(XmlAccessType.NONE)
+public class Country {
+
+ @XmlAttribute(name="code")
+ private String code;
+
+ @XmlValue
+ private String name;
+
+ /**
+ * @return The two letter country code.
+ */
+ public String getCountryCode() {
+ return code;
+ }
+
+ /**
+ * Set the two letter country code.
+ *
+ * This class does not attempt to resolve the country name from the country code.
+ * When the country code is set the name will become null.
+
+ * @param code A two letter countey code.
+ * @throws IllegalArgumentException if the country code is not valid.
+ */
+ public void setCountryCode(final String code) {
+ if (code.length() != 2) {
+ throw new IllegalArgumentException("Argument must be a two letter country code.");
+ }
+ this.code = code.toUpperCase();
+ this.name = null;
+ }
+
+ /**
+ * @return The country name or null if the country name is unknown.
+ */
+ public String getName() {
+ return name;
+ }
+}