From fd769e58927c2b5fb2600c6d1c97463ce709c559 Mon Sep 17 00:00:00 2001 From: Markus Frohme Date: Fri, 5 Jul 2024 14:10:47 +0200 Subject: [PATCH] remove mutability from PropertyOracles --- CHANGELOG.md | 1 + .../java/de/learnlib/oracle/PropertyOracle.java | 8 -------- .../oracle/property/AbstractPropertyOracle.java | 7 +------ .../oracle/property/LoggingPropertyOracle.java | 5 ----- .../oracle/property/MealyFinitePropertyOracle.java | 1 - .../oracle/property/PropertyOracleChain.java | 14 +------------- 6 files changed, 3 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d8190ffa..6508f5bceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * The `de.learnlib.tooling:learnlib-annotation-processor` artifact has been dropped. The functionality has been moved to a [standalone project](https://github.com/LearnLib/build-tools). * The `de.learnlib:learnlib-rpni-edsm` and `de.learnlib:learnlib-rpni-mdl` artifacts have been dropped. The code has been merged with the `de.learnlib:learnlib-rpni` artifact. +* `PropertyOracle`s can no longer set a property. This value is now immutable and must be provided during instantiation. Previously, the internal state wasn't updated accordingly if a property was overridden. ## [0.17.0] - 2023-11-15 diff --git a/api/src/main/java/de/learnlib/oracle/PropertyOracle.java b/api/src/main/java/de/learnlib/oracle/PropertyOracle.java index c53e6d2364..46b3086fd6 100644 --- a/api/src/main/java/de/learnlib/oracle/PropertyOracle.java +++ b/api/src/main/java/de/learnlib/oracle/PropertyOracle.java @@ -53,14 +53,6 @@ default boolean isDisproved() { return getCounterExample() != null; } - /** - * Set the property. - * - * @param property - * the property to set - */ - void setProperty(P property); - /** * Returns the property. * diff --git a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/AbstractPropertyOracle.java b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/AbstractPropertyOracle.java index 5276d8f1bc..9aef5a45a0 100644 --- a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/AbstractPropertyOracle.java +++ b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/AbstractPropertyOracle.java @@ -44,7 +44,7 @@ abstract class AbstractPropertyOracle, P, D, R extends private final InclusionOracle inclusionOracle; private final EmptinessOracle emptinessOracle; - private P property; + private final P property; private @Nullable DefaultQuery counterExample; protected AbstractPropertyOracle(P property, @@ -60,11 +60,6 @@ protected AbstractPropertyOracle(P property, return counterExample; } - @Override - public void setProperty(P property) { - this.property = property; - } - @Override public P getProperty() { return property; diff --git a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/LoggingPropertyOracle.java b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/LoggingPropertyOracle.java index 5f6ea64a6d..1e6d749280 100644 --- a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/LoggingPropertyOracle.java +++ b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/LoggingPropertyOracle.java @@ -62,11 +62,6 @@ public boolean isDisproved() { return propertyOracle.isDisproved(); } - @Override - public void setProperty(P property) { - this.propertyOracle.setProperty(property); - } - @Override public P getProperty() { return propertyOracle.getProperty(); diff --git a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/MealyFinitePropertyOracle.java b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/MealyFinitePropertyOracle.java index 20532ceb8b..bb4c33e636 100644 --- a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/MealyFinitePropertyOracle.java +++ b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/MealyFinitePropertyOracle.java @@ -49,7 +49,6 @@ public MealyFinitePropertyOracle(P property, @Override protected MealyMachine modelCheck(MealyMachine hypothesis, Collection inputs) { - return modelChecker.findCounterExample(hypothesis, inputs, getProperty()); } } diff --git a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/PropertyOracleChain.java b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/PropertyOracleChain.java index 46d191258e..f67edf3954 100644 --- a/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/PropertyOracleChain.java +++ b/oracles/property-oracles/src/main/java/de/learnlib/oracle/property/PropertyOracleChain.java @@ -77,7 +77,7 @@ generics = {@Generic("I"), @Generic("O"), @Generic("P")})) public class PropertyOracleChain, @Nullable P, D> implements PropertyOracle { - private P property; + private final P property; private @Nullable DefaultQuery counterExample; @@ -97,12 +97,6 @@ public PropertyOracleChain(Collection oracle) { - assert oracle.getProperty() == null || oracle.getProperty().equals(property); - oracle.setProperty(property); - oracles.add(oracle); - } - @Override public @Nullable DefaultQuery doFindCounterExample(A hypothesis, Collection inputs) { for (PropertyOracle oracle : oracles) { @@ -128,12 +122,6 @@ public void addOracle(PropertyOracle oracle) { return null; } - @Override - public void setProperty(P property) { - oracles.forEach(o -> o.setProperty(property)); - this.property = property; - } - @Override public P getProperty() { return property;