pl.edu.icm.unity.stdext.attr.VerifiableEmailAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unity-server-std-plugins Show documentation
Show all versions of unity-server-std-plugins Show documentation
Standard plugins which are distributed with the system:
attribute syntaxes, identity types, credentials
/*
* Copyright (c) 2013 ICM Uniwersytet Warszawski All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package pl.edu.icm.unity.stdext.attr;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import pl.edu.icm.unity.JsonUtil;
import pl.edu.icm.unity.stdext.utils.EmailUtils;
import pl.edu.icm.unity.types.basic.Attribute;
import pl.edu.icm.unity.types.basic.VerifiableEmail;
/**
* Helper class allowing to create verifiable email attributes easily.
* @author P. Piernik
*/
public class VerifiableEmailAttribute
{
public static Attribute of(String name, String groupPath, String value)
{
return of(name, groupPath, EmailUtils.convertFromString(value));
}
/**
* Automatically converts {@link VerifiableEmail} parameters to strings.
* @param name
* @param groupPath
* @param values
*/
public static Attribute of(String name, String groupPath, VerifiableEmail... values)
{
return new Attribute(name, VerifiableEmailAttributeSyntax.ID, groupPath,
Stream.of(values).
map(v -> JsonUtil.serialize(v.toJson())).collect(Collectors.toList()));
}
}