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

io.imunity.scim.user.User Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.scim.user;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;

import pl.edu.icm.unity.base.attribute.AttributeExt;
import pl.edu.icm.unity.base.group.Group;
import pl.edu.icm.unity.base.identity.Identity;

public class User
{
	final Long entityId;
	public final List identities;
	public final Set groups;
	public final List attributes;

	private User(Builder builder)
	{
		this.entityId = builder.entityId;
		this.identities = List.copyOf(builder.identities);
		this.groups = Set.copyOf(builder.groups);
		this.attributes = List.copyOf(builder.attributes);
	}

	@Override
	public int hashCode()
	{
		return Objects.hash(attributes, entityId, groups, identities);
	}



	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		return Objects.equals(attributes, other.attributes) && Objects.equals(entityId, other.entityId)
				&& Objects.equals(groups, other.groups) && Objects.equals(identities, other.identities);
	}

	public static Builder builder()
	{
		return new Builder();
	}

	public static final class Builder
	{
		private Long entityId;
		private List identities = Collections.emptyList();
		private Set groups = Collections.emptySet();
		private List attributes = Collections.emptyList();

		private Builder()
		{
		}

		public Builder withEntityId(Long entityId)
		{
			this.entityId = entityId;
			return this;
		}

		public Builder withIdentities(List identities)
		{
			this.identities = identities;
			return this;
		}

		public Builder withGroups(Set groups)
		{
			this.groups = groups;
			return this;
		}

		public Builder withAttributes(List attributes)
		{
			this.attributes = attributes;
			return this;
		}

		public User build()
		{
			return new User(this);
		}
	}

	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy