package skadistats.clarity.model;

import skadistats.clarity.model.state.EntityState;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public interface DTClass {

    String getDtName();

    int getClassId();
    void setClassId(int classId);

    EntityState getEmptyState();

    String getNameForFieldPath(FieldPath fp);
    FieldPath getFieldPathForName(String property);

    @Deprecated
    default List<FieldPath> collectFieldPaths(EntityState state) {
        List<FieldPath> result = new ArrayList<>();
        Iterator<FieldPath> iter = state.fieldPathIterator();
        while (iter.hasNext()) {
            result.add(iter.next());
        }
        return result;
    }

}


@@ -26,24 +26,112 @@
 y.model;%0D%0A%0D%0A
+import skadistats.clarity.io.s1.S1DTClass;%0D%0Aimport skadistats.clarity.io.s2.S2DTClass;%0D%0A
 import skadi
@@ -252,16 +252,53 @@
 l.List;%0D
+%0Aimport java.util.function.Function;%0D
 %0A%0D%0Apubli
@@ -864,13 +864,273 @@
    %7D%0D%0A%0D%0A
+    default %3CV%3E V evaluate(Function%3CS1DTClass, V%3E s1, Function%3CS2DTClass, V%3E s2) %7B%0D%0A        if (this instanceof S2DTClass) %7B%0D%0A            return s2.apply((S2DTClass) this);%0D%0A        %7D else %7B%0D%0A            return s1.apply((S1DTClass) this);%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A
 %7D%0D%0A%0D%0A

add utility function to evaluate something depending on whether source 1 or source 2