Skip to content
Snippets Groups Projects
Commit 97377ac4 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

Fix Missing rule verifier for string values

parent 26e228b4
No related branches found
No related tags found
No related merge requests found
package de.unikoblenz.fgbks.base.utils.boundary.bicreater;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_NOT_IN_CONTACT;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.SUBSUMES;
import de.unikoblenz.fgbks.base.utils.boundary.impl.StringBoundary;
import java.util.Arrays;
......@@ -11,8 +11,11 @@ import java.util.Set;
/**
* The lower bound creator implementation of {@link BoundaryBiCreaterType#LOWER_BOUNDS} for {@link
* StringBoundary}. <br> The result is a new boundary with the lower bounds, or an empty optional,
* if the creation is not possible. <br> In: {@code b1: "a","b"; b2: "a"}<br> Out: {@code "b"} <br>
* StringBoundary}. <br>
* The result is a new boundary with the lower bounds, or an empty optional, if the creation is not
* possible. <br>
* In: {@code b1: "a"; b2: "a", "b"}<br>
* Out: {@code "b"} <br>
*/
public class BiCreaterStringLowerBounds extends AbstractBoundaryBiCreater<StringBoundary> {
......@@ -38,17 +41,47 @@ public class BiCreaterStringLowerBounds extends AbstractBoundaryBiCreater<String
@Override
public Optional<StringBoundary> create(StringBoundary b1, StringBoundary b2) {
if (b1.checkWith(IS_NOT_IN_CONTACT, b2) || b1.checkWith(IS_EQUAL, b2)) {
if (b2.matchesAny()) {
return Optional.empty();
}
if (b1.matchesAny() || b1.matchesNoneOfValues()) {
if (b1.matchesAny()) {
return Optional.of(
StringBoundary.getBuilder()
.matchesNoneOfValues(!b2.matchesNoneOfValues())
.addValues(b2.getValues())
.build());
}
if (b2.checkWith(IS_EQUAL, b1) || b2.checkWith(SUBSUMES, b1)) {
return Optional.empty();
}
if (b1.matchesNoneOfValues()) {
if (b2.matchesNoneOfValues()) {
Set<String> values = new HashSet<>(Arrays.asList(b2.getValues()));
values.removeAll(Arrays.asList(b1.getValues()));
if (values.size() == 0) {
return Optional.empty();
}
return Optional.of(StringBoundary.getBuilder().addValues(values).build());
} else {
return Optional.of(
StringBoundary.getBuilder()
.matchesNoneOfValues(true)
.addValues(b1.getValues())
.addValues(b2.getValues())
.build());
}
}
if (b2.matchesNoneOfValues()) {
return Optional.of(
StringBoundary.getBuilder()
.addValues(b1.getValues())
.addValues(b2.getValues())
.matchesNoneOfValues(!b2.matchesNoneOfValues())
.build());
}
Set<String> values = new HashSet<>(Arrays.asList(b1.getValues()));
values.removeAll(Arrays.asList(b2.getValues()));
return Optional.of(StringBoundary.getBuilder().addValues(values).build());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment