aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/InferredType.java
blob: fd05158bf8bb6da97ce9e56b65448b52380b1434 (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
30
31
32
33
34
35
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.reasoning.translator.typehierarchy;

import tools.refinery.store.reasoning.representation.PartialRelation;

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

record InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConcreteTypes,
					PartialRelation currentType) {
	public static final InferredType UNTYPED = new InferredType(Set.of(), Set.of(), null);

	public InferredType(Set<PartialRelation> mustTypes, Set<PartialRelation> mayConcreteTypes,
						PartialRelation currentType) {
		this.mustTypes = Collections.unmodifiableSet(mustTypes);
		this.mayConcreteTypes = Collections.unmodifiableSet(mayConcreteTypes);
		this.currentType = currentType;
	}

	public boolean isConsistent() {
		return currentType != null || mustTypes.isEmpty();
	}

	public boolean isMust(PartialRelation partialRelation) {
		return mustTypes.contains(partialRelation);
	}

	public boolean isMayConcrete(PartialRelation partialRelation) {
		return mayConcreteTypes.contains(partialRelation);
	}
}