com.memority.citadel.shared.api.context.ObjectContextAttributesHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of citadel-api Show documentation
Show all versions of citadel-api Show documentation
This artifact provides the API classes that are necessary to implement general configuration Rules on the Memority IM platform.
/*
* 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.context;
import com.memority.citadel.shared.api.im.AttributeValue;
import com.memority.citadel.shared.api.im.EntityId;
import com.memority.citadel.shared.api.im.ObjectId;
import java.util.List;
import java.util.stream.Collectors;
public class ObjectContextAttributesHelper {
public static AttributeValue> convertObjectValueIdentifier(AttributeValue> attributeValue) {
if (attributeValue.getValues().isEmpty()) {
return attributeValue;
}
List> values = attributeValue.getValues().stream()
.map(value -> {
if (value instanceof ObjectId) {
return ((ObjectId) value).getValue();
}
if (value instanceof EntityId) {
return ((EntityId) value).getValue();
}
return value;
})
.collect(Collectors.toList());
return AttributeValue.from(attributeValue.getId(), values, attributeValue.getMultiValuedState());
}
}