package org.skyve.impl.metadata.repository;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

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

/**
 * JAXB Adapter for Map<String, String> to/from PropertyMapType.
 */
public class PropertyMapAdapter extends XmlAdapter<PropertyMapType, Map<String, String>> {
	@Override
	public Map<String, String> unmarshal(PropertyMapType v) throws Exception {
		Map<String, String> result = new TreeMap<>();
		for (PropertyMapEntryType property : v.properties) {
			result.put(property.key, property.value);
		}
		return result;
	}

	@Override
	public PropertyMapType marshal(Map<String, String> v) throws Exception {
		PropertyMapType result = new PropertyMapType();

		List<PropertyMapEntryType> properties = result.properties;
		for (Entry<String, String> entry : v.entrySet()) {
			PropertyMapEntryType property = new PropertyMapEntryType();
			property.key = entry.getKey();
			property.value = entry.getValue();
			properties.add(property);
		}

		return result;
	}
}

@@ -724,24 +724,65 @@
 ype result =
+ null;%0A%09%09if (! v.isEmpty()) %7B%0A%09%09%09result =
  new Propert
@@ -793,17 +793,17 @@
 Type();%0A
-%0A
+%09
 %09%09List%3CP
@@ -855,16 +855,17 @@
 erties;%0A
+%09
 %09%09for (E
@@ -912,16 +912,17 @@
 )) %7B%0A%09%09%09
+%09
 Property
@@ -972,24 +972,25 @@
 yType();%0A%09%09%09
+%09
 property.key
@@ -1004,24 +1004,25 @@
 y.getKey();%0A
+%09
 %09%09%09property.
@@ -1050,16 +1050,17 @@
 e();%0A%09%09%09
+%09
 properti
@@ -1077,20 +1077,27 @@
 perty);%0A
+%09%09%09%7D%0A
 %09%09%7D%0A
+%09%09
 %0A%09%09retur

Stop property elements being generated on DecoratedMetaData classes when generating edit views.