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

pl.edu.icm.unity.stdext.attr.VerifiableEmailAttribute Maven / Gradle / Ivy

Go to download

Standard plugins which are distributed with the system: attribute syntaxes, identity types, credentials

There is a newer version: 4.0.2
Show newest version
/*
 * 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()));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy