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

com.memority.citadel.shared.api.im.RightGrantDimensionsAdapter Maven / Gradle / Ivy

Go to download

This artifact provides the API classes that are necessary to implement general configuration Rules on the Memority IM platform.

There is a newer version: 3.43.1
Show newest version
/*
 * Copyright (c) 2016-2023 Memority. All Rights Reserved.
 *
 * This file is part of Memority Citadel API , a Memority project.
 *
 * This file is released under the Memority Public Artifacts End-User License Agreement,
 * see 
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 */
package com.memority.citadel.shared.api.im;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

public class RightGrantDimensionsAdapter
		extends XmlAdapter> {

	@Override
	public Map unmarshal(Dims dims) {
		if (dims == null) {
			return null;
		}

		return Optional.ofNullable(dims.getEntries()).orElse(Collections.emptyList()).stream().collect(Collectors.toMap(Dim::getKey, Dim::getValue));
	}

	@Override
	public Dims marshal(Map map) {
		if(map == null) {
			return null;
		}

		List entries = map.entrySet().stream()
				.map(e -> new Dim(e.getKey(), e.getValue()))
				.collect(Collectors.toList());

		return new Dims(entries);
	}

	@Data
	@NoArgsConstructor
	@AllArgsConstructor
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Dims {

		@XmlElement(name = "dim")
		private List entries;

	}

	@Data
	@NoArgsConstructor
	@AllArgsConstructor
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Dim {

		@XmlAttribute
		private String key;

		@XmlValue
		private Object value;
	}

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy