package au.gov.ga.geodesy.support.mapper.dozer;

import org.dozer.CustomConverter;
import org.dozer.MappingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.opengis.iso19139.gco.v_20070417.CodeListValueType;

/**
 * Convert: java.lang.String <--> net.opengis.gml.v_3_2_1.CodeListValueType
 * 
 * Also handles these extending classes:
 * au.gov.xml.icsm.geodesyml.v_0_3.IgsReceiverModelCodeType
 * au.gov.xml.icsm.geodesyml.v_0_3.IgsAntennaModelCodeType
 * 
 */
public class CodeListValueTypeConverter implements CustomConverter {
    Logger logger = LoggerFactory.getLogger(getClass());

    @SuppressWarnings("rawtypes")
    public Object convert(Object destination, Object source, Class destClass, Class sourceClass) {
        if (source == null) {
            return null;
        }

        if (source instanceof String) {
            Object destClassInstance = null;
            if (destination == null) {
                try {
                    destClassInstance = destClass.newInstance();
                } catch (InstantiationException | IllegalAccessException e) {
                    logger.error("Error createing Dozer destination", e);
                }
            } else {
                destClassInstance = destination;
            }
            ((CodeListValueType) destClassInstance).setValue((String) source);
            return destClassInstance;
        } else if (source instanceof CodeListValueType) {
            return ((CodeListValueType) source).getValue();
        } else {
            throw new MappingException("Converter " + getClass().getName()
                    + "used incorrectly. Arguments passed in were:" + destination + " and " + source);
        }
    }
}

@@ -1291,72 +1291,276 @@
     
-((CodeListValueType) destClassInstance).setValue((String) source
+CodeListValueType destClassInstanceType =  (CodeListValueType) destClassInstance;%0A            destClassInstanceType.setValue((String) source);%0A            destClassInstanceType.setCodeList(%22codelist%22);%0A            destClassInstanceType.setCodeListValue(%22codeListValue%22
 );%0A 

Update translate to output codeList and codeListValue