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

org.molgenis.data.index.Impact Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.data.index;

import com.google.auto.value.AutoValue;
import org.molgenis.data.EntityKey;

import javax.annotation.Nullable;

/**
 * Value object to store the impact of changes.
 */
@AutoValue
@SuppressWarnings("squid:S1610") // Abstract classes without fields should be converted to interfaces
public abstract class Impact
{
	public abstract String getEntityTypeId();

	@Nullable
	public abstract Object getId();

	public boolean isWholeRepository()
	{
		return getId() == null;
	}

	public EntityKey toEntityKey()
	{
		return EntityKey.create(getEntityTypeId(), getId());
	}

	public boolean isSingleEntity()
	{
		return getId() != null;
	}

	public static Impact createSingleEntityImpact(String entityTypeId, Object id)
	{
		return new AutoValue_Impact(entityTypeId, id);
	}

	public static Impact createWholeRepositoryImpact(String entityTypeId)
	{
		return new AutoValue_Impact(entityTypeId, null);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy