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

io.imunity.scim.group.SCIMGroupResource 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.group;

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

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import io.imunity.scim.common.BasicSCIMResource;
import io.imunity.scim.schema.DefaultSchemaProvider;

@JsonDeserialize(builder = SCIMGroupResource.Builder.class)
class SCIMGroupResource extends BasicSCIMResource
{
	static final String SCHEMA = DefaultSchemaProvider.DEFAULT_GROUP_SCHEMA_ID;

	public final String displayName;
	public final List members;

	private SCIMGroupResource(Builder builder)
	{
		super(builder);
		this.displayName = builder.displayName;
		this.members = List.copyOf(builder.members);
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + Objects.hash(displayName, members);
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		SCIMGroupResource other = (SCIMGroupResource) obj;
		return Objects.equals(displayName, other.displayName) && Objects.equals(members, other.members);
	}

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

	static final class Builder extends BasicScimResourceBuilder
	{
		private String displayName;
		private List members = Collections.emptyList();

		private Builder()
		{
			withSchemas(Set.of(SCHEMA));
		}

		public Builder withDisplayName(String displayName)
		{
			this.displayName = displayName;
			return this;
		}

		public Builder withMembers(List members)
		{
			this.members = members;
			return this;
		}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy