diff options
Diffstat (limited to 'subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java')
-rw-r--r-- | subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java index 07d1d19b..542acdb3 100644 --- a/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java +++ b/subprojects/store-reasoning/src/main/java/tools/refinery/store/reasoning/translator/PartialSymbolTranslator.java | |||
@@ -12,7 +12,6 @@ import tools.refinery.store.reasoning.refinement.PartialInterpretationRefiner; | |||
12 | import tools.refinery.store.reasoning.refinement.PartialModelInitializer; | 12 | import tools.refinery.store.reasoning.refinement.PartialModelInitializer; |
13 | import tools.refinery.store.reasoning.refinement.StorageRefiner; | 13 | import tools.refinery.store.reasoning.refinement.StorageRefiner; |
14 | import tools.refinery.store.reasoning.representation.PartialSymbol; | 14 | import tools.refinery.store.reasoning.representation.PartialSymbol; |
15 | import tools.refinery.store.reasoning.seed.Seed; | ||
16 | import tools.refinery.store.reasoning.seed.SeedInitializer; | 15 | import tools.refinery.store.reasoning.seed.SeedInitializer; |
17 | import tools.refinery.store.representation.AnySymbol; | 16 | import tools.refinery.store.representation.AnySymbol; |
18 | import tools.refinery.store.representation.Symbol; | 17 | import tools.refinery.store.representation.Symbol; |
@@ -100,20 +99,6 @@ public abstract sealed class PartialSymbolTranslator<A, C> implements AnyPartial | |||
100 | return this; | 99 | return this; |
101 | } | 100 | } |
102 | 101 | ||
103 | public <T> PartialSymbolTranslator<A, C> seed(Seed<T> seed) { | ||
104 | if (storageSymbol == null) { | ||
105 | throw new IllegalArgumentException("Seed requires setting a storage symbol"); | ||
106 | } | ||
107 | if (!seed.valueType().equals(storageSymbol.valueType())) { | ||
108 | throw new IllegalArgumentException("Seed type %s does not match storage symbol type %s" | ||
109 | .formatted(seed.valueType(), storageSymbol.valueType())); | ||
110 | } | ||
111 | // The guard clause only allows a well-typed seed. | ||
112 | @SuppressWarnings("unchecked") | ||
113 | var typedStorageSymbol = (Symbol<T>) storageSymbol; | ||
114 | return initializer(new SeedInitializer<>(typedStorageSymbol, seed)); | ||
115 | } | ||
116 | |||
117 | @Override | 102 | @Override |
118 | public void configure(ModelStoreBuilder storeBuilder) { | 103 | public void configure(ModelStoreBuilder storeBuilder) { |
119 | checkNotConfigured(); | 104 | checkNotConfigured(); |
@@ -132,6 +117,7 @@ public abstract sealed class PartialSymbolTranslator<A, C> implements AnyPartial | |||
132 | registerStorageRefiner(reasoningBuilder, storageRefiner); | 117 | registerStorageRefiner(reasoningBuilder, storageRefiner); |
133 | } | 118 | } |
134 | } | 119 | } |
120 | createFallbackInitializer(); | ||
135 | if (initializer != null) { | 121 | if (initializer != null) { |
136 | reasoningBuilder.initializer(initializer); | 122 | reasoningBuilder.initializer(initializer); |
137 | } | 123 | } |
@@ -144,6 +130,17 @@ public abstract sealed class PartialSymbolTranslator<A, C> implements AnyPartial | |||
144 | reasoningBuilder.storageRefiner(typedStorageSymbol, factory); | 130 | reasoningBuilder.storageRefiner(typedStorageSymbol, factory); |
145 | } | 131 | } |
146 | 132 | ||
133 | private void createFallbackInitializer() { | ||
134 | if (initializer == null && | ||
135 | storageSymbol != null && | ||
136 | storageSymbol.valueType().equals(partialSymbol.abstractDomain().abstractType())) { | ||
137 | // The guard clause makes this safe. | ||
138 | @SuppressWarnings("unchecked") | ||
139 | var typedStorageSymbol = (Symbol<A>) storageSymbol; | ||
140 | initializer = new SeedInitializer<>(typedStorageSymbol, partialSymbol); | ||
141 | } | ||
142 | } | ||
143 | |||
147 | public PartialInterpretation.Factory<A, C> getInterpretationFactory() { | 144 | public PartialInterpretation.Factory<A, C> getInterpretationFactory() { |
148 | checkConfigured(); | 145 | checkConfigured(); |
149 | return interpretationFactory; | 146 | return interpretationFactory; |