A few minor tweaks to the MassiveStore database accessor system.

This commit is contained in:
Olof Larsson 2015-05-15 12:23:05 +02:00
parent 78e272cdb4
commit 413f485e0c
2 changed files with 7 additions and 5 deletions

View File

@ -21,7 +21,7 @@ public class Accessor
public Class<?> getClazz() { return this.clazz; }
private Map<String, FieldAccessor> fieldToAccessor = new LinkedHashMap<String, FieldAccessor>();
public Map<String, FieldAccessor> getFieldToAccessor() { return this.fieldToAccessor; }
public Map<String, FieldAccessor> getFieldToAccessor() { return this.fieldToAccessor; }
public FieldAccessor getFieldAccessor(String fieldName)
{
@ -50,14 +50,15 @@ public class Accessor
{
Accessor ret = classToAccessor.get(clazz);
if (ret != null) return ret;
return new Accessor(clazz);
ret = new Accessor(clazz);
classToAccessor.put(clazz, ret);
return ret;
}
private Accessor(Class<?> clazz)
{
this.clazz = clazz;
this.populate();
classToAccessor.put(clazz, this);
}
// -------------------------------------------- //
@ -145,7 +146,6 @@ public class Accessor
if (Modifier.isFinal(field.getModifiers())) continue;
String fieldName = field.getName();
if (ret.containsKey(fieldName)) continue;
field.setAccessible(true);
ret.put(fieldName, field);
}

View File

@ -2,6 +2,8 @@ package com.massivecraft.massivecore.store.accessor;
import java.lang.reflect.Field;
import com.massivecraft.massivecore.util.ReflectionUtil;
public class FieldAccessor
{
// -------------------------------------------- //
@ -16,7 +18,7 @@ public class FieldAccessor
public FieldAccessor(Field field)
{
field.setAccessible(true);
ReflectionUtil.makeAccessible(field);
this.field = field;
}