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

de.retest.ui.review.ActionChangeSet Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
package de.retest.ui.review;

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

import de.retest.ui.descriptors.Element;
import de.retest.ui.descriptors.IdentifyingAttributes;

public class ActionChangeSet {

	private final String description;

	public ActionChangeSet() {
		this( null );
	}

	public ActionChangeSet( final String description ) {
		this.description = description;
	}

	private final AttributeChanges identAttributeChanges = new AttributeChanges();

	public AttributeChanges getIdentAttributeChanges() {
		return identAttributeChanges;
	}

	private final AttributeChanges attributeChanges = new AttributeChanges();

	public AttributeChanges getAttributesChanges() {
		return attributeChanges;
	}

	private final Set insertChanges = new HashSet();

	public boolean containsInsertChange( final Element element ) {
		return insertChanges.contains( element );
	}

	public void addInsertChange( final Element element ) {
		insertChanges.add( element );
	}

	public void removeInsertChange( final Element element ) {
		insertChanges.remove( element );
	}

	public Set getInsertedChanges() {
		return Collections.unmodifiableSet( insertChanges );
	}

	private final Set deletedChanges = new HashSet();

	public boolean containsDeletedChange( final IdentifyingAttributes identifyingAttributes ) {
		return deletedChanges.contains( identifyingAttributes );
	}

	public void addDeletedChange( final IdentifyingAttributes identifyingAttributes ) {
		deletedChanges.add( identifyingAttributes );
	}

	public void removeDeletedChange( final IdentifyingAttributes identifyingAttributes ) {
		deletedChanges.remove( identifyingAttributes );
	}

	public Set getDeletedChanges() {
		return Collections.unmodifiableSet( deletedChanges );
	}

	public boolean isEmpty() {
		return identAttributeChanges.isEmpty() && attributeChanges.isEmpty() && insertChanges.isEmpty()
				&& deletedChanges.isEmpty();
	}

	private int size() {
		return identAttributeChanges.size() + attributeChanges.size() + insertChanges.size() + deletedChanges.size();
	}

	@Override
	public String toString() {
		return "ActionChangeSet [" + size() + " changes]";
	}

	public String getDescription() {
		return description;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy