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

io.imunity.scim.common.Meta Maven / Gradle / Ivy

/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */

package io.imunity.scim.common;

import java.net.URI;
import java.time.Instant;
import java.util.Objects;

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

@JsonDeserialize(builder = Meta.Builder.class)
public class Meta
{
	public final String resourceType;
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	public final Instant created;
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	public final Instant lastModified;
	public final URI location;
	@JsonInclude(JsonInclude.Include.NON_EMPTY)
	public final String version;

	private Meta(Builder builder)
	{
		this.resourceType = builder.resourceType;
		this.created = builder.created;
		this.lastModified = builder.lastModified;
		this.location = builder.location;
		this.version = builder.version;
	}

	@Override
	public int hashCode()
	{
		return Objects.hash(created, lastModified, location, resourceType, version);
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Meta other = (Meta) obj;
		return Objects.equals(created, other.created) && Objects.equals(lastModified, other.lastModified)
				&& Objects.equals(location, other.location) && resourceType == other.resourceType
				&& Objects.equals(version, other.version);
	}

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

	public static final class Builder
	{
		private String resourceType;
		private Instant created;
		private Instant lastModified;
		private URI location;
		private String version;

		private Builder()
		{
		}

		public Builder withResourceType(String resourceType)
		{
			this.resourceType = resourceType;
			return this;
		}

		public Builder withCreated(Instant created)
		{
			this.created = created;
			return this;
		}

		public Builder withLastModified(Instant lastModified)
		{
			this.lastModified = lastModified;
			return this;
		}

		public Builder withLocation(URI location)
		{
			this.location = location;
			return this;
		}

		public Builder withVersion(String version)
		{
			this.version = version;
			return this;
		}

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy