1 package org.kuali.common.util.xml.jaxb.adapter; 2 3 import javax.xml.bind.annotation.adapters.XmlAdapter; 4 5 import com.google.common.base.Optional; 6 7 public class OmitOptionalIntegerAdapter extends XmlAdapter<Integer, Optional<Integer>> { 8 9 @Override 10 public Integer marshal(Optional<Integer> optional) { 11 if (optional.isPresent()) { 12 return optional.get(); 13 } else { 14 return null; 15 } 16 } 17 18 @Override 19 public Optional<Integer> unmarshal(Integer value) { 20 if (value == null) { 21 return Optional.<Integer> absent(); 22 } else { 23 return Optional.<Integer> of(value); 24 } 25 } 26 27 }