All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.retest.ui.descriptors.AttributesAdapter Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
package de.retest.ui.descriptors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class AttributesAdapter
		extends XmlAdapter> {

	@XmlRootElement
	public static class PersistableAttributes implements Serializable {
		private static final long serialVersionUID = 1L;

		@XmlElement
		public List attribute = new ArrayList();
	}

	@Override
	public PersistableAttributes marshal( final SortedMap toPersist ) throws Exception {
		if ( null == toPersist ) {
			return null;
		}
		final PersistableAttributes persistableAttributes = new PersistableAttributes();
		persistableAttributes.attribute.addAll( toPersist.values() );
		return persistableAttributes;
	}

	@Override
	public SortedMap unmarshal( final PersistableAttributes toLoad ) throws Exception {
		if ( null == toLoad ) {
			return null;
		}
		final SortedMap result = new TreeMap();
		for ( final Attribute attribute : toLoad.attribute ) {
			result.put( attribute.getKey(), attribute );
		}
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy