Spot more modification

This commit is contained in:
BuildTools 2015-11-28 17:23:10 +01:00 committed by Olof Larsson
parent a0685d0b5b
commit c9466eb3c5
2 changed files with 77 additions and 74 deletions

View File

@ -528,6 +528,10 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
// Then attach!
this.attach(entity, id, false);
// On creation it might be modified by addition or removal of new/old fields.
// So we must do a check for that.
entity.changed();
}
entity.setLastRaw(raw);
@ -782,7 +786,6 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
@Override
public void identifyModifications(Modification veto)
{
// Get remote id2mtime snapshot
Map<String, Long> id2RemoteMtime = this.getDb().getId2mtime(this);
@ -960,7 +963,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
@Override
public void init()
{
if (this.inited()) return; // TODO: Would throwing an exception make more sense?
if (this.inited()) throw new IllegalStateException("Already initialised.");
if (this.supportsPusher())
{
@ -968,7 +971,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
}
this.initLoadAllFromRemote();
// this.syncAll();
this.syncIdentified();
name2instance.put(this.getName(), this);
}
@ -976,7 +979,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
@Override
public void deinit()
{
if ( ! this.inited()) return; // TODO: Would throwing an exception make more sense?
if ( ! this.inited()) throw new IllegalStateException("Not initialised.");
if (this.supportsPusher())
{

View File

@ -1,70 +1,70 @@
package com.massivecraft.massivecore.store;
import java.util.HashMap;
import java.util.Map;
public class IndexUniqueField<F, O>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private Map<F, O> f2o;
private Map<O, F> o2f;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public IndexUniqueField(Map<F, O> map)
{
this.f2o = map;
this.o2f = new HashMap<O, F>();
}
// -------------------------------------------- //
// STUFF
// -------------------------------------------- //
public void update(O object, F field)
{
if (object == null) return;
if (field == null) return;
this.f2o.put(field, object);
this.o2f.put(object, field);
}
public O removeField(F field)
{
if (field == null) return null;
O object = this.f2o.remove(field);
if (object != null) this.o2f.remove(object);
return object;
}
public F removeObject(O object)
{
if (object == null) return null;
F field = this.o2f.remove(object);
if (field != null) this.f2o.remove(object);
return field;
}
public O getObject(F field)
{
if (field == null) return null;
return this.f2o.get(field);
}
public F getField(O object)
{
if (object == null) return null;
return this.o2f.get(object);
}
}
package com.massivecraft.massivecore.store;
import java.util.HashMap;
import java.util.Map;
public class IndexUniqueField<F, O>
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private Map<F, O> f2o;
private Map<O, F> o2f;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public IndexUniqueField(Map<F, O> map)
{
this.f2o = map;
this.o2f = new HashMap<O, F>();
}
// -------------------------------------------- //
// STUFF
// -------------------------------------------- //
public void update(O object, F field)
{
if (object == null) return;
if (field == null) return;
this.f2o.put(field, object);
this.o2f.put(object, field);
}
public O removeField(F field)
{
if (field == null) return null;
O object = this.f2o.remove(field);
if (object != null) this.o2f.remove(object);
return object;
}
public F removeObject(O object)
{
if (object == null) return null;
F field = this.o2f.remove(object);
if (field != null) this.f2o.remove(object);
return field;
}
public O getObject(F field)
{
if (field == null) return null;
return this.f2o.get(field);
}
public F getField(O object)
{
if (object == null) return null;
return this.o2f.get(object);
}
}