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 OmitClassAdapter extends XmlAdapter<Class<?>, Class<?>> { 8 9 public OmitClassAdapter(Class<?> omitClass) { 10 Assert.noNulls(omitClass); 11 this.omitClass = omitClass; 12 } 13 14 private final Class<?> omitClass; 15 16 @Override 17 public final Class<?> marshal(Class<?> value) { 18 if (omitClass == value) { 19 return null; 20 } else { 21 return value; 22 } 23 } 24 25 @Override 26 public final Class<?> unmarshal(Class<?> value) { 27 if (value == null) { 28 return omitClass; 29 } else { 30 return value; 31 } 32 } 33 34 public final Class<?> getOmitClass() { 35 return omitClass; 36 } 37 38 }