From abc8f6a39f4af28746f155365b1ba8673bc33ef8 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 9 Jan 2020 13:53:22 +0200 Subject: [PATCH] Getters for specific class UpdateOps gitlab #20 Change-Id: Ic40fd6d18dca5839fa179083bbb754de1869aac9 --- .../interop/update/model/UpdateOp.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java index 50954ec..3b633c2 100644 --- a/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java +++ b/org.simantics.interop.update/src/org/simantics/interop/update/model/UpdateOp.java @@ -2,6 +2,7 @@ package org.simantics.interop.update.model; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.simantics.db.Resource; import org.simantics.db.Statement; @@ -37,10 +38,26 @@ public abstract class UpdateOp { return parentOps; } + public Collection getParentOpsWithClass(Class cls) { + List ops = new ArrayList(parentOps.size()); + for (UpdateOp op : parentOps) + if (cls.isAssignableFrom(op.getClass())) + ops.add((T)op); + return ops; + } + public Collection getSubOps() { return subOps; } + public Collection getSubOpsWithClass(Class cls) { + List ops = new ArrayList(subOps.size()); + for (UpdateOp op : subOps) + if (cls.isAssignableFrom(op.getClass())) + ops.add((T)op); + return ops; + } + public void addParentOp(UpdateOp op) { assert (!op.equals(this)); parentOps.add(op); -- 2.47.1