Verified Commit 8e904e40 authored by Jonathan Haas's avatar Jonathan Haas
Browse files

ProcessingParameterBuilder ergänzt

parent 99aa2683
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -281,11 +281,11 @@ public final class ProcessingParameter {
	 * @param mainObject      Hauptobjekt (kann null sein)
	 * @param simVar          Simulationsvariante
	 * @param periods         Zeitintervalle des Protokolls.
	 * @param aspBindings     Aspekt-Bindungen oder {@link java.util.Collections#EMPTY_MAP} falls keine gewünscht sind.
	 * @param pseudoObjects   Pseudo-Objekt-Definitionen oder {@link java.util.Collections#EMPTY_MAP} falls keine gewünscht sind.
	 * @param aspBindings     Aspekt-Bindungen oder {@link Collections#EMPTY_MAP} falls keine gewünscht sind.
	 * @param pseudoObjects   Pseudo-Objekt-Definitionen oder {@link Collections#EMPTY_MAP} falls keine gewünscht sind.
	 * @param saveProtocol    Ob das Protokoll gespeichert werden soll
	 * @param protocolType    Zu erstellende Protokollart. <code>null</code> wird als {@link de.bsvrz.sys.funclib.losb.datk.ProtocolType#Undefined} interpretiert.
	 * @param noChangeMarker  Markierungsart für "Keine Änderungen" bei Zustandsprotokollen, entweder Zeilenweise oder für jede einzelne Zelle/jeden einzelnen Datensatz. <code>null</code> wird als {@link de.bsvrz.sys.funclib.losb.datk.NoChangeMarker#Undefined} interpretiert.
	 * @param protocolType    Zu erstellende Protokollart. <code>null</code> wird als {@link ProtocolType#Undefined} interpretiert.
	 * @param noChangeMarker  Markierungsart für "Keine Änderungen" bei Zustandsprotokollen, entweder Zeilenweise oder für jede einzelne Zelle/jeden einzelnen Datensatz. <code>null</code> wird als {@link NoChangeMarker#Undefined} interpretiert.
	 * @param archiveDataKind Liste mit Datensatzarten für die das Protokoll erstellt werden soll
	 * @param creatorName     Name des Erstellers
	 * @param isPublic        Ist das Protokoll öffentlich?
+123 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 by Kappich Systemberatung Aachen
 * ALL RIGHTS RESERVED.
 */

package de.bsvrz.pua.prot.util;

import com.google.common.collect.ImmutableMap;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKind;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKindCombination;
import de.bsvrz.dav.daf.main.config.SystemObject;
import de.bsvrz.sys.funclib.kappich.annotations.NotNull;
import de.bsvrz.sys.funclib.kappich.annotations.Nullable;
import de.bsvrz.sys.funclib.losb.datk.NoChangeMarker;
import de.bsvrz.sys.funclib.losb.datk.ProtocolType;
import de.bsvrz.sys.funclib.losb.exceptions.FailureException;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class ProcessingParameterBuilder {
	@NotNull
	private final SystemObject _script;
	@Nullable
	private SystemObject _mainObject = null;
	
	private short _simVar = (short) 0;
	@NotNull
	private PeriodSet _periods = PeriodSet.of();
	@NotNull
	private Map<String, String> _aspBindings = ImmutableMap.of();
	@NotNull
	private Map<String, List<String>> _pseudoObjects = ImmutableMap.of();
	
	private boolean _saveProtocol = false;
	@NotNull
	private ProtocolType _protocolType = ProtocolType.StatusProtocol;
	@NotNull
	private NoChangeMarker _noChangeMarker = NoChangeMarker.Row;
	@NotNull
	private Collection<ArchiveDataKind> _archiveDataKinds = ArchiveDataKindCombination.all();
	@NotNull
	private String _creatorName = "";
	
	private boolean _isPublic = true;
	@NotNull
	private String _infoText = "";

	public ProcessingParameterBuilder(final SystemObject script) {
		_script = Objects.requireNonNull(script);
	}

	public ProcessingParameterBuilder withMainObject(final SystemObject mainObject) {
		_mainObject = mainObject;
		return this;
	}

	public ProcessingParameterBuilder withSimVar(final short simVar) {
		_simVar = simVar;
		return this;
	}

	public ProcessingParameterBuilder withPeriods(final PeriodSet periods) {
		_periods = periods;
		return this;
	}

	public ProcessingParameterBuilder withAspBindings(final Map<String, String> aspBindings) {
		_aspBindings = Objects.requireNonNull(aspBindings);
		return this;
	}

	public ProcessingParameterBuilder withPseudoObjects(final Map<String, List<String>> pseudoObjects) {
		_pseudoObjects = Objects.requireNonNull(pseudoObjects);
		return this;
	}

	public ProcessingParameterBuilder withSaveProtocol(final boolean saveProtocol) {
		_saveProtocol = saveProtocol;
		return this;
	}

	public ProcessingParameterBuilder withProtocolType(final ProtocolType protocolType) {
		_protocolType = Objects.requireNonNull(protocolType);
		return this;
	}

	public ProcessingParameterBuilder withNoChangeMarker(final NoChangeMarker noChangeMarker) {
		_noChangeMarker = Objects.requireNonNull(noChangeMarker);
		return this;
	}

	public ProcessingParameterBuilder withArchiveDataKinds(final Collection<ArchiveDataKind> archiveDataKind) {
		_archiveDataKinds = Objects.requireNonNull(archiveDataKind);
		return this;
	}

	public ProcessingParameterBuilder withCreatorName(final String creatorName) {
		_creatorName = Objects.requireNonNull(creatorName);
		return this;
	}

	public ProcessingParameterBuilder withIsPublic(final boolean isPublic) {
		_isPublic = isPublic;
		return this;
	}

	public ProcessingParameterBuilder withInfoText(final String infoText) {
		_infoText = Objects.requireNonNull(infoText);
		return this;
	}

	public ProcessingParameter build() {
		try {
			return new ProcessingParameter(_script, _mainObject, _simVar, _periods, _aspBindings, _pseudoObjects, _saveProtocol, _protocolType, _noChangeMarker, _archiveDataKinds, _creatorName, _isPublic, _infoText);
		}
		catch(FailureException e) {
			throw new IllegalArgumentException(e);
		}
	}
}