mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 04:53:54 +00:00
Moved the criterias package to the sse bundle
This commit is contained in:
1 parent
ca9eb1d40f
commit
1a4131ccaf
11 files changed
+14
-15
No files matched your search
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import com.sap.sse.datamining.components.FilterCriteria;
|
||||
|
||||
public class AndCompoundFilterCriteria<DataType> extends CompoundFilterCriteria<DataType> {
|
||||
|
||||
@Override
|
||||
public boolean matches(DataType data) {
|
||||
for (FilterCriteria<DataType> criteria : getCriterias()) {
|
||||
if (!criteria.matches(data)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import com.sap.sse.datamining.data.Dimension;
|
||||
|
||||
public class DimensionRegexFilterCriteria<DataType> extends RegexFilterCriteria<DataType> {
|
||||
|
||||
private Dimension<DataType, String> dimension;
|
||||
|
||||
public DimensionRegexFilterCriteria(String regex, Dimension<DataType, String> dimension) {
|
||||
super(regex);
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getValueToMatch(DataType data) {
|
||||
return dimension.getDimensionValueFrom(data);
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.sap.sse.datamining.components.FilterCriteria;
|
||||
import com.sap.sse.datamining.data.Dimension;
|
||||
|
||||
public class DimensionValuesFilterCriteria<DataType, ValueType> implements FilterCriteria<DataType> {
|
||||
|
||||
private Dimension<DataType, ValueType> dimension;
|
||||
private Collection<ValueType> values;
|
||||
|
||||
public DimensionValuesFilterCriteria(Dimension<DataType, ValueType> dimension, Collection<ValueType> values) {
|
||||
this.dimension = dimension;
|
||||
this.values = new HashSet<ValueType>(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(DataType data) {
|
||||
ValueType dataValue = dimension.getDimensionValueFrom(data);
|
||||
if (dataValue == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ValueType value : values) {
|
||||
if (value.equals(dataValue)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.sap.sse.datamining.components.FilterCriteria;
|
||||
import com.sap.sse.datamining.functions.Function;
|
||||
|
||||
public class NullaryFunctionFilterCriteria<DataType, ValueType> implements FilterCriteria<DataType> {
|
||||
|
||||
private Function<ValueType> function;
|
||||
private Collection<ValueType> valuesToMatch;
|
||||
|
||||
public NullaryFunctionFilterCriteria(Function<ValueType> function, Collection<ValueType> valuesToMatch) {
|
||||
this.function = function;
|
||||
this.valuesToMatch = new HashSet<>(valuesToMatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(DataType dataEntry) {
|
||||
ValueType value = function.tryToInvoke(dataEntry);
|
||||
|
||||
for (ValueType valueToMatch : valuesToMatch) {
|
||||
if (Objects.equals(value, valueToMatch)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import com.sap.sse.datamining.components.FilterCriteria;
|
||||
import com.sap.sse.datamining.data.ClusterOfComparable;
|
||||
|
||||
public abstract class RangeFilterCriteria<DataType, ValueType extends Comparable<ValueType>> implements FilterCriteria<DataType> {
|
||||
|
||||
private ClusterOfComparable<ValueType> cluster;
|
||||
|
||||
public RangeFilterCriteria(ClusterOfComparable<ValueType> cluster) {
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(DataType data) {
|
||||
return isInRange(data);
|
||||
}
|
||||
|
||||
protected boolean isInRange(DataType data) {
|
||||
return cluster.isInRange(getValue(data));
|
||||
}
|
||||
|
||||
public abstract ValueType getValue(DataType data);
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import com.sap.sse.datamining.components.FilterCriteria;
|
||||
|
||||
public abstract class RegexFilterCriteria<DataType> implements FilterCriteria<DataType> {
|
||||
|
||||
private String regex;
|
||||
|
||||
public RegexFilterCriteria(String regex) {
|
||||
this.regex = regex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(DataType data) {
|
||||
String valueToMatch = getValueToMatch(data);
|
||||
return valueToMatch != null && valueToMatch.matches(regex);
|
||||
}
|
||||
|
||||
protected abstract String getValueToMatch(DataType data);
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.sap.sse.datamining.impl.criterias;
|
||||
|
||||
import com.sap.sse.datamining.data.ClusterOfComparable;
|
||||
|
||||
public class SimpleRangeFilterCriteria<DataType extends Comparable<DataType>> extends RangeFilterCriteria<DataType, DataType> {
|
||||
|
||||
public SimpleRangeFilterCriteria(ClusterOfComparable<DataType> cluster) {
|
||||
super(cluster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataType getValue(DataType data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user