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

com.github.thorbenkuck.keller.repository.ActionStack Maven / Gradle / Ivy

The newest version!
package com.github.thorbenkuck.keller.repository;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;

final class ActionStack {

	private final List> predicateList = new ArrayList<>();
	private final List> consumers = new ArrayList<>();
	private final List ifPresent = new ArrayList<>();
	private final List ifNotPresent = new ArrayList<>();
	private final List matchingObjects = new ArrayList<>();
	private final RepositoryInternals internals;
	private T primaryMatchingElement;
	private T nullObject;
	private Class clazz;

	ActionStack(final RepositoryInternals internals, final Class clazz) {
		this.internals = internals;
		this.clazz = clazz;
	}

	public List> getPredicateList() {
		return predicateList;
	}

	public List getIfPresent() {
		return ifPresent;
	}

	public void addIfPresent(final Runnable ifPresent) {
		this.ifPresent.add(ifPresent);
	}

	public List getIfNotPresent() {
		return ifNotPresent;
	}

	public void addIfNotPresent(final Runnable ifNotPresent) {
		this.ifNotPresent.add(ifNotPresent);
	}

	public List getMatchingObjects() {
		return matchingObjects;
	}

	public void addMatchingObject(T t) {
		matchingObjects.add(t);
		if(primaryMatchingElement == null) {
			setPrimaryMatchingElement(t);
		}
	}

	public Class getType() {
		return clazz;
	}

	public T getPrimaryMatchingElement() {
		return primaryMatchingElement;
	}

	public void setPrimaryMatchingElement(final T primaryMatchingElement) {
		this.primaryMatchingElement = primaryMatchingElement;
	}

	public void addPredicate(final Predicate predicate) {
		this.predicateList.add(predicate);
	}

	public T getNullObject() {
		return nullObject;
	}

	public void setNullObject(final T nullObject) {
		this.nullObject = nullObject;
	}

	public RepositoryInternals getInternals() {
		return internals;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy