/** * Adds a given new value for <b>prefix</b> () * * <p> * <b>Definition:</b> * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name * </p> * @param theValue The prefix to add (must not be <code>null</code>) */ public HumanNameDt addPrefix(StringDt theValue) { if (theValue == null) { throw new NullPointerException("theValue must not be null"); } getPrefix().add(theValue); return this; }
/** * Gets the first repetition for <b>prefix</b> (), * creating it if it does not already exist. * * <p> * <b>Definition:</b> * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name * </p> */ public StringDt getPrefixFirstRep() { if (getPrefix().isEmpty()) { return addPrefix(); } return getPrefix().get(0); } /**
/** * Adds and returns a new value for <b>prefix</b> () * * <p> * <b>Definition:</b> * Part of the name that is acquired as a title due to academic, legal, employment or nobility status, etc. and that appears at the start of the name * </p> */ public StringDt addPrefix() { StringDt newType = new StringDt(); getPrefix().add(newType); return newType; }
@Override public String toString(HumanNameDt name) { StringBuilder sb = new StringBuilder(); append(sb, name.getPrefix()); append(sb, name.getFamily()); sb.append(","); append(sb, name.getGiven()); append(sb, name.getSuffix()); return sb.toString(); }
@Override public String serialize(HumanNameDt value) { return getComponent(value.getFamily(), 0) + NAME_DELIM + getComponent(value.getGiven(), 0) + NAME_DELIM + getComponent(value.getGiven(), 1) + NAME_DELIM + getComponent(value.getSuffix(), 0) + NAME_DELIM + getComponent(value.getPrefix(), 0) + NAME_DELIM + getComponent(value.getSuffix(), 1) + NAME_DELIM + value.getUse(); }
@Test public void test() { NameSerializer ns = new NameSerializer(); HumanNameDt name = new HumanNameDt(); name.addFamily("Martin"); name.addGiven("Douglas"); name.addGiven("Kent"); name.addPrefix("Dr."); name.addSuffix("M.D."); name.getUseElement().setValueAsEnum(NameUseEnum.OFFICIAL); String s = ns.serialize(name); System.out.println(s); HumanNameDt name2 = ns.deserialize(s); assertEquals(name.getFamily(), name2.getFamily()); assertEquals(name.getGiven(), name2.getGiven()); assertEquals(name.getPrefix(), name2.getPrefix()); assertEquals(name.getSuffix(), name2.getSuffix()); assertEquals(name.getUse(), name2.getUse()); }