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

com.github.zeger_tak.enversvalidationplugin.entities.AuditTableInformation Maven / Gradle / Ivy

Go to download

This is a Maven plugin that allows for easy validation of database auditing with Hibernate and is intended to be used by projects that do not always rely on Envers to create the audit history.

There is a newer version: 0.6
Show newest version
package com.github.zeger_tak.enversvalidationplugin.entities;

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

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class AuditTableInformation
{
	private final String auditTableName;
	private final String contentTableName;
	private final Set columnNamesPresentInContentTableButNotInAuditTable;

	private AuditTableInformation auditTableParent;

	public AuditTableInformation(@Nonnull String auditTableName, @Nonnull String contentTableName)
	{
		this(auditTableName, contentTableName, Collections.emptySet());
	}

	public AuditTableInformation(@Nonnull String auditTableName, @Nonnull String contentTableName, @Nonnull Set columnNamesPresentInContentTableButNotInAuditTable)
	{
		this.auditTableName = auditTableName;
		this.contentTableName = contentTableName;
		this.columnNamesPresentInContentTableButNotInAuditTable = columnNamesPresentInContentTableButNotInAuditTable;
	}

	@Nonnull
	public String getAuditTableName()
	{
		return auditTableName;
	}

	@CheckForNull
	public AuditTableInformation getAuditTableParent()
	{
		return auditTableParent;
	}

	public void setAuditTableParent(@Nullable AuditTableInformation auditTableParent)
	{
		this.auditTableParent = auditTableParent;
	}

	@Nonnull
	public String getContentTableName()
	{
		return contentTableName;
	}

	@Nonnull
	public Set getColumnNamesPresentInContentTableButNotInAuditTable()
	{
		final Set allColumnNamesPresentInContentTableButNotInAuditTable = new HashSet<>(columnNamesPresentInContentTableButNotInAuditTable);
		if (auditTableParent != null)
		{
			allColumnNamesPresentInContentTableButNotInAuditTable.addAll(auditTableParent.getColumnNamesPresentInContentTableButNotInAuditTable());
		}
		return Collections.unmodifiableSet(allColumnNamesPresentInContentTableButNotInAuditTable);
	}

	@Override
	public boolean equals(Object o)
	{
		if (this == o)
		{
			return true;
		}
		if (o == null || getClass() != o.getClass())
		{
			return false;
		}
		AuditTableInformation that = (AuditTableInformation) o;
		return Objects.equals(auditTableName, that.auditTableName);
	}

	@Override
	public int hashCode()
	{
		return Objects.hash(auditTableName);
	}

	@Override
	public String toString()
	{
		return "AuditTableInformation[auditTableName='" + auditTableName + (auditTableParent == null ? "" : "', auditTableParent='" + auditTableParent) + "', contentTableName='" + contentTableName + "']";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy