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

com.nedap.archie.xml.adapters.StringDictionaryUtil Maven / Gradle / Ivy

There is a newer version: 3.12.0
Show newest version
package com.nedap.archie.xml.adapters;

import com.nedap.archie.xml.types.StringDictionaryItem;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by pieter.bos on 01/08/16.
 */
public class StringDictionaryUtil {
    
    public static ArrayList convertUriMapIntoStringDictionaryList(Map terms) {
        if(terms == null) {
            return null;
        }
        ArrayList items = new ArrayList<>();
        for(String termId: terms.keySet()) {
            StringDictionaryItem item = new StringDictionaryItem();
            item.setId(termId);
            item.setValue(terms.get(termId).toString());
            items.add(item);
        }
        return items;
    }

    public static ArrayList convertStringMapIntoStringDictionaryList(Map terms) {
        if(terms == null) {
            return null;
        }
        ArrayList items = new ArrayList<>();
        for(String termId: terms.keySet()) {
            StringDictionaryItem item = new StringDictionaryItem();
            item.setId(termId);
            item.setValue(terms.get(termId));
            items.add(item);
        }
        return items;
    }

    public static Map convertStringDictionaryListToUriMap(List items) throws URISyntaxException {
        if(items == null) {
            return null;
        }
        Map termMap = new LinkedHashMap<>();
        for(StringDictionaryItem term:items) {
            termMap.put(term.getId(), new URI(term.getValue()));
        }
        return termMap;
    }

    public static LinkedHashMap convertStringDictionaryListToStringMap(List items) {
        if(items == null) {
            return null;
        }
        LinkedHashMap termMap = new LinkedHashMap<>();
        for(StringDictionaryItem term:items) {
            termMap.put(term.getId(),term.getValue());
        }
        return termMap;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy