Skip Headers

# Using Java

Previous

Next

To configure a mapping with a `JAXBTypesafeEnumConverter` in Java, use a descriptor amendment method (see "Configuring Amendment Methods"). Example: Creating a JAXB Typesafe Enumeration XML Mapping illustrates an amendment method that configures an `XMLDirectMapping` with a `JAXBTypesafeEnumConverter`. In this example, attribute `_Val` is mapped to a JAXB typesafe enumeration corresponding to typesafe enumeration class `MyTypesafeEnum`.

Creating a JAXB Typesafe Enumeration XML Mapping

    public class DescriptorAfterLoads {
        public static void amendRootImplDescriptor(ClassDescriptor descriptor) {
            DatabaseMapping _ValMapping = descriptor.getMappingForAttributeName("_Val");
            JAXBTypesafeEnumConverter _ValConverter = new JAXBTypesafeEnumConverter();
            ValConverter.setEnumClassName("MyTypesafeEnum");
            ((XMLDirectMapping) _ValMapping).setConverter(_ValConverter);
        }
    }