diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java index 9f897e46..e6bdaff2 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/typehierarchy/TypeInfo.java | |||
@@ -9,43 +9,15 @@ import tools.refinery.store.reasoning.representation.PartialRelation; | |||
9 | 9 | ||
10 | import java.util.*; | 10 | import java.util.*; |
11 | 11 | ||
12 | public record TypeInfo(Collection<PartialRelation> supertypes, boolean abstractType) { | 12 | public record TypeInfo(Set<PartialRelation> supertypes, boolean abstractType) { |
13 | public static Builder builder() { | 13 | public TypeInfo(Collection<PartialRelation> supertypes, boolean abstractType) { |
14 | return new Builder(); | 14 | this(Set.copyOf(supertypes), abstractType); |
15 | } | 15 | } |
16 | 16 | ||
17 | public static class Builder { | 17 | public TypeInfo addSupertype(PartialRelation newSupertype) { |
18 | private final Set<PartialRelation> supertypes = new LinkedHashSet<>(); | 18 | var newSupertypes = new ArrayList<PartialRelation>(supertypes.size() + 1); |
19 | private boolean abstractType; | 19 | newSupertypes.addAll(supertypes); |
20 | 20 | newSupertypes.add(newSupertype); | |
21 | private Builder() { | 21 | return new TypeInfo(newSupertypes, abstractType); |
22 | } | ||
23 | |||
24 | public Builder supertypes(Collection<PartialRelation> supertypes) { | ||
25 | this.supertypes.addAll(supertypes); | ||
26 | return this; | ||
27 | } | ||
28 | |||
29 | public Builder supertypes(PartialRelation... supertypes) { | ||
30 | return supertypes(List.of(supertypes)); | ||
31 | } | ||
32 | |||
33 | public Builder supertype(PartialRelation supertype) { | ||
34 | supertypes.add(supertype); | ||
35 | return this; | ||
36 | } | ||
37 | |||
38 | public Builder abstractType(boolean abstractType) { | ||
39 | this.abstractType = abstractType; | ||
40 | return this; | ||
41 | } | ||
42 | |||
43 | public Builder abstractType() { | ||
44 | return abstractType(true); | ||
45 | } | ||
46 | |||
47 | public TypeInfo build() { | ||
48 | return new TypeInfo(Collections.unmodifiableSet(supertypes), abstractType); | ||
49 | } | ||
50 | } | 22 | } |
51 | } | 23 | } |