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