}
public static void writeTruthMaintenanceSystem(
MarshallerWriteContext context,
ProtobufMessages.RuleData.Builder _session) throws IOException {
ObjectHashMap assertMap = context.wm.getTruthMaintenanceSystem()
.getAssertMap();
ObjectHashMap justifiedMap = context.wm.getTruthMaintenanceSystem()
.getJustifiedMap();
if (!assertMap.isEmpty() || !justifiedMap.isEmpty()) {
EqualityKey[] keys = new EqualityKey[assertMap.size()];
org.drools.core.util.Iterator it = assertMap.iterator();
int i = 0;
for (org.drools.core.util.ObjectHashMap.ObjectEntry entry = (org.drools.core.util.ObjectHashMap.ObjectEntry) it
.next(); entry != null; entry = (org.drools.core.util.ObjectHashMap.ObjectEntry) it
.next()) {
EqualityKey key = (EqualityKey) entry.getKey();
keys[i++] = key;
}
Arrays.sort(keys, EqualityKeySorter.instance);
ProtobufMessages.TruthMaintenanceSystem.Builder _tms = ProtobufMessages.TruthMaintenanceSystem
.newBuilder();
// write the assert map of Equality keys
for (EqualityKey key : keys) {
ProtobufMessages.EqualityKey.Builder _key = ProtobufMessages.EqualityKey
.newBuilder();
_key.setStatus(key.getStatus());
_key.setHandleId(key.getFactHandle().getId());
if (key.getOtherFactHandle() != null
&& !key.getOtherFactHandle().isEmpty()) {
for (InternalFactHandle handle : key.getOtherFactHandle()) {
_key.addOtherHandle(handle.getId());
}
}
_tms.addKey(_key.build());
}
it = justifiedMap.iterator();
i = 0;
for (org.drools.core.util.ObjectHashMap.ObjectEntry entry = (org.drools.core.util.ObjectHashMap.ObjectEntry) it
.next(); entry != null; entry = (org.drools.core.util.ObjectHashMap.ObjectEntry) it
.next()) {
ProtobufMessages.Justification.Builder _justification = ProtobufMessages.Justification