From d69a61d6c2bf372c6d0cfbec5edd81483f2cf0b7 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 16 Jan 2013 11:05:47 +0100 Subject: [PATCH] Move all field initialization to the constructor. --- src/com/massivecraft/mcore5/store/Coll.java | 32 ++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/com/massivecraft/mcore5/store/Coll.java b/src/com/massivecraft/mcore5/store/Coll.java index 023d61f3..7f92c2a1 100644 --- a/src/com/massivecraft/mcore5/store/Coll.java +++ b/src/com/massivecraft/mcore5/store/Coll.java @@ -70,7 +70,7 @@ public class Coll> implements CollInterface ids = new ConcurrentSkipListSet(); + protected Set ids; @Override public Collection getIds() { return Collections.unmodifiableCollection(this.ids); } @Override public Collection getIdsRemote() { return this.getDb().getDriver().getIds(this); } @Override public boolean containsEntity(Object entity) { return this.entities.contains(entity); }; @@ -84,14 +84,14 @@ public class Coll> implements CollInterface entities = new ConcurrentSkipListSet(); + protected Set entities; @Override public Collection getAll() { return Collections.unmodifiableCollection(this.entities); } @Override public Collection getAll(Predictate where) { return MStoreUtil.uglySQL(this.getAll(), where, null, null, null); } @Override public Collection getAll(Predictate where, Comparator orderby) { return MStoreUtil.uglySQL(this.getAll(), where, orderby, null, null); } @Override public Collection getAll(Predictate where, Comparator orderby, Integer limit) { return MStoreUtil.uglySQL(this.getAll(), where, orderby, limit, null); } @Override public Collection getAll(Predictate where, Comparator orderby, Integer limit, Integer offset) { return MStoreUtil.uglySQL(this.getAll(), where, orderby, limit, offset); } - protected Map id2entity = new ConcurrentHashMap(); + protected Map id2entity; @Override public Map getId2entity() { return Collections.unmodifiableMap(this.id2entity); } @Override public E get(Object oid) @@ -114,7 +114,7 @@ public class Coll> implements CollInterface entity2id = new ConcurrentHashMap(); + protected Map entity2id; @Override public Map getEntity2id() { return Collections.unmodifiableMap(this.entity2id); } @Override public L getId(Object entity) { return this.entity2id.get(entity); } @@ -278,9 +278,9 @@ public class Coll> implements CollInterface localAttachIds = Collections.newSetFromMap(new ConcurrentHashMap()); - protected Set localDetachIds = Collections.newSetFromMap(new ConcurrentHashMap()); - protected Set changedIds = Collections.newSetFromMap(new ConcurrentHashMap()); + protected Set localAttachIds; + protected Set localDetachIds; + protected Set changedIds; protected synchronized void clearIdentifiedChanges(L id) { @@ -561,10 +561,12 @@ public class Coll> implements CollInterface> implements CollInterface(); + this.entities = new ConcurrentSkipListSet(); + this.id2entity = new ConcurrentHashMap(); + this.entity2id = new ConcurrentHashMap(); + + // IDENTIFIED CHANGES + this.localAttachIds = Collections.newSetFromMap(new ConcurrentHashMap()); + this.localDetachIds = Collections.newSetFromMap(new ConcurrentHashMap()); + this.changedIds = Collections.newSetFromMap(new ConcurrentHashMap()); + + // SYNCLOG + this.lastMtime = new ConcurrentHashMap(); + this.lastRaw = new ConcurrentHashMap(); + this.lastDefault = Collections.newSetFromMap(new ConcurrentHashMap()); + final Coll me = this; this.tickTask = new Runnable() {