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

pl.edu.icm.unity.stdext.attr.VerifiableMobileNumberAttribute 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.base.attribute.Attribute;
import pl.edu.icm.unity.base.json.JsonUtil;
import pl.edu.icm.unity.base.verifiable.VerifiableMobileNumber;
import pl.edu.icm.unity.stdext.utils.MobileNumberUtils;

/**
 * Helper class allowing to create verifiable mobile number attributes easily.
 * @author P. Piernik
 */
public class VerifiableMobileNumberAttribute
{
	public static Attribute of(String name, String groupPath, String value)
	{
		return of(name, groupPath, MobileNumberUtils.convertFromString(value));
	}

	/**
	 * Automatically converts {@link VerifiableMobileNumber} parameters to strings.
	 * @param name
	 * @param groupPath
	 * @param values
	 */
	public static Attribute of(String name, String groupPath, VerifiableMobileNumber... values)
	{
		return new Attribute(name, VerifiableMobileNumberAttributeSyntax.ID, groupPath, 
				Stream.of(values).
				map(v -> JsonUtil.serialize(v.toJson())).collect(Collectors.toList()));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy