1 package org.kuali.common.util.xml.jaxb.adapter; 2 3 import javax.xml.bind.annotation.adapters.XmlAdapter; 4 5 import org.kuali.common.util.Assert; 6 7 public abstract class OmitStringAdapter extends XmlAdapter<String, String> { 8 9 public OmitStringAdapter(String omitString) { 10 Assert.notNull(omitString); 11 this.omitString = omitString; 12 } 13 14 private final String omitString; 15 16 @Override 17 public final String marshal(String string) { 18 if (omitString.equals(string)) { 19 return null; 20 } else { 21 return string; 22 } 23 } 24 25 @Override 26 public final String unmarshal(String string) { 27 if (string == null) { 28 return omitString; 29 } else { 30 return string; 31 } 32 } 33 34 public final String getOmitString() { 35 return omitString; 36 } 37 38 }