/** * Clears all cached objects */ public void clear() { getReflectionCache().clear(); }
/** * Clears all cached objects */ public void clear() { getReflectionCache().clear(); }
/** * @return the size of the cache (number of cached {@link ClassFields} entries) */ public int size() { return getReflectionCache().size(); }
/** * @return the size of the cache (number of cached {@link ClassFields} entries) */ public int size() { return getReflectionCache().size(); }
/** * Setting to determine if the result of "getClass()" should be included in the reflection data <br/> * <b>WARNING</b>: changing this will clear the existing cache * * @param includeClassField if true then getClass() will be treated as a readable field called "class", default is false */ public void setIncludeClassField(boolean includeClassField) { if (this.includeClassField != includeClassField) { // need to clear the cache if we change this getReflectionCache().clear(); } this.includeClassField = includeClassField; } public boolean isIncludeClassField() {
/** * Setting to determine if the result of "getClass()" should be included in the reflection data <br/> * <b>WARNING</b>: changing this will clear the existing cache * * @param includeClassField if true then getClass() will be treated as a readable field called "class", default is false */ public void setIncludeClassField(boolean includeClassField) { if (this.includeClassField != includeClassField) { // need to clear the cache if we change this getReflectionCache().clear(); } this.includeClassField = includeClassField; } public boolean isIncludeClassField() {
/** * Set the cache to be used for holding the reflection data, * this allows control over where the reflection caches are stored, * this should store the data in a way that it will not hold open the classloader the class comes from <br/> * Note that you can set this to a map implementation which does not store anything to disable caching if you like * * @param reflectionCache a cache for holding class cache data (implements map), null to use the default internal cache */ @SuppressWarnings("unchecked") public void setReflectionCache(Map<Class<?>, ClassFields> reflectionCache) { if (reflectionCache != null) { this.reflectionCache.clear(); this.reflectionCache = reflectionCache; } else { getReflectionCache(); } }
/** * Set the cache to be used for holding the reflection data, * this allows control over where the reflection caches are stored, * this should store the data in a way that it will not hold open the classloader the class comes from <br/> * Note that you can set this to a map implementation which does not store anything to disable caching if you like * * @param reflectionCache a cache for holding class cache data (implements map), null to use the default internal cache */ @SuppressWarnings("unchecked") public void setReflectionCache(Map<Class<?>, ClassFields> reflectionCache) { if (reflectionCache != null) { this.reflectionCache.clear(); this.reflectionCache = reflectionCache; } else { getReflectionCache(); } }
/** * Set the mode used to find fields on classes (default {@link FieldFindMode#HYBRID}) <br/> * <b>WARNING</b>: changing modes will clear the existing cache * * @param fieldFindMode see FieldFindMode enum for details * @see FieldFindMode */ public void setFieldFindMode(FieldFindMode fieldFindMode) { if (fieldFindMode == null) { fieldFindMode = FieldFindMode.HYBRID; } if (! this.fieldFindMode.equals(fieldFindMode)) { // need to clear the cache if we change the mode getReflectionCache().clear(); } this.fieldFindMode = fieldFindMode; } public FieldFindMode getFieldFindMode() {
/** * Set the mode used to find fields on classes (default {@link FieldFindMode#HYBRID}) <br/> * <b>WARNING</b>: changing modes will clear the existing cache * * @param fieldFindMode see FieldFindMode enum for details * @see FieldFindMode */ public void setFieldFindMode(FieldFindMode fieldFindMode) { if (fieldFindMode == null) { fieldFindMode = FieldFindMode.HYBRID; } if (! this.fieldFindMode.equals(fieldFindMode)) { // need to clear the cache if we change the mode getReflectionCache().clear(); } this.fieldFindMode = fieldFindMode; } public FieldFindMode getFieldFindMode() {
ClassFields<T> cf = getReflectionCache().get(cls); if (cf != null && !mode.equals(cf.getFieldFindMode())) { cf = null; getReflectionCache().put(cls, cf); cacheMisses++; } else {
ClassFields<T> cf = getReflectionCache().get(cls); if (cf != null && !mode.equals(cf.getFieldFindMode())) { cf = null; getReflectionCache().put(cls, cf); cacheMisses++; } else {