more stuff I did

This commit is contained in:
2025-07-13 02:36:21 +02:00
parent 867e5e2097
commit 5f9f80edbe
12 changed files with 154 additions and 95 deletions

View File

@@ -10,13 +10,16 @@ public class AttributeEquals implements BiFunction<List<Attribute>, List<Object>
private final Attribute rhs;
public AttributeEquals(Attribute lhs, Attribute rhs) {
assert lhs != null;
assert rhs != null;
assert lhs.type().equals(rhs.type());
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
return rows.get(attributes.indexOf(lhs)).equals(rows.get(attributes.indexOf(rhs)));
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
return tuple.get(attributes.indexOf(lhs)).equals(tuple.get(attributes.indexOf(rhs)));
}
}

View File

@@ -10,14 +10,17 @@ public class GreaterThan implements BiFunction<List<Attribute>, List<Object>, Bo
private final Integer value;
public GreaterThan(Attribute attribute, Integer value) {
assert attribute != null && attribute.type().equals(Integer.class);
assert value != null;
this.attribute = attribute;
this.value = value;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
var columnIndex = attributes.indexOf(attribute);
assert attributes.get(columnIndex).type().equals(Integer.class);
return ((Integer) rows.get(columnIndex)) > value;
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
var attributeIndex = attributes.indexOf(attribute);
assert attributes.get(attributeIndex).type().equals(Integer.class);
return ((Integer) tuple.get(attributeIndex)) > value;
}
}

View File

@@ -10,14 +10,17 @@ public class GreaterThanEquals implements BiFunction<List<Attribute>, List<Objec
private final Integer value;
public GreaterThanEquals(Attribute attribute, Integer value) {
assert attribute != null && attribute.type().equals(Integer.class);
assert value != null;
this.attribute = attribute;
this.value = value;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
var columnIndex = attributes.indexOf(attribute);
assert attributes.get(columnIndex).type().equals(Integer.class);
return ((Integer) rows.get(columnIndex)) >= value;
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
var attributeIndex = attributes.indexOf(attribute);
assert attributes.get(attributeIndex).type().equals(Integer.class);
return ((Integer) tuple.get(attributeIndex)) >= value;
}
}

View File

@@ -10,14 +10,17 @@ public class LessThan implements BiFunction<List<Attribute>, List<Object>, Boole
private final Integer value;
public LessThan(Attribute attribute, Integer value) {
assert attribute != null && attribute.type().equals(Integer.class);
assert value != null;
this.attribute = attribute;
this.value = value;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
var columnIndex = attributes.indexOf(attribute);
assert attributes.get(columnIndex).type().equals(Integer.class);
return ((Integer) rows.get(columnIndex)) < value;
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
var attributeIndex = attributes.indexOf(attribute);
assert attributes.get(attributeIndex).type().equals(Integer.class);
return ((Integer) tuple.get(attributeIndex)) < value;
}
}

View File

@@ -10,14 +10,17 @@ public class LessThanEquals implements BiFunction<List<Attribute>, List<Object>,
private final Integer value;
public LessThanEquals(Attribute attribute, Integer value) {
assert attribute != null && attribute.type().equals(Integer.class);
assert value != null;
this.attribute = attribute;
this.value = value;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
var columnIndex = attributes.indexOf(attribute);
assert attributes.get(columnIndex).type().equals(Integer.class);
return ((Integer) rows.get(columnIndex)) <= value;
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
var attributeIndex = attributes.indexOf(attribute);
assert attributes.get(attributeIndex).type().equals(Integer.class);
return ((Integer) tuple.get(attributeIndex)) <= value;
}
}

View File

@@ -6,14 +6,16 @@ import java.util.List;
import java.util.function.BiFunction;
public class Not implements BiFunction<List<Attribute>, List<Object>, Boolean> {
private BiFunction<List<Attribute>, List<Object>, Boolean> condition;
private final BiFunction<List<Attribute>, List<Object>, Boolean> condition;
public Not(BiFunction<List<Attribute>, List<Object>, Boolean> condition) {
assert condition != null;
this.condition = condition;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> objects) {
return !condition.apply(attributes, objects);
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
return !condition.apply(attributes, tuple);
}
}

View File

@@ -10,13 +10,16 @@ public class ValueEquals implements BiFunction<List<Attribute>, List<Object>, Bo
private final Object rhs;
public ValueEquals(Attribute lhs, Object rhs) {
assert lhs != null;
assert rhs != null;
assert lhs.type().isInstance(rhs);
this.lhs = lhs;
this.rhs = rhs;
}
@Override
public Boolean apply(List<Attribute> attributes, List<Object> rows) {
return rows.get(attributes.indexOf(lhs)).equals(rhs);
public Boolean apply(List<Attribute> attributes, List<Object> tuple) {
return tuple.get(attributes.indexOf(lhs)).equals(rhs);
}
}