aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/logic/src/main/java/tools/refinery/logic/dnf/FunctionalQueryBuilder.java
blob: 476f3c835cdb90ec0845038e1a39ace3ed6f5178 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.logic.dnf;

import tools.refinery.logic.term.DataVariable;

public final class FunctionalQueryBuilder<T> extends AbstractQueryBuilder<FunctionalQueryBuilder<T>> {
	private final DataVariable<T> outputVariable;
	private final Class<T> type;

	FunctionalQueryBuilder(DataVariable<T> outputVariable, DnfBuilder dnfBuilder, Class<T> type) {
		super(dnfBuilder);
		this.outputVariable = outputVariable;
		this.type = type;
	}

	@Override
	protected FunctionalQueryBuilder<T> self() {
		return this;
	}

	public FunctionalQuery<T> build() {
		dnfBuilder.output(outputVariable);
		return dnfBuilder.build().asFunction(type);
	}
}