@Nullable private TypeDescriptor getTypeDescriptor(EvaluationContext context, Object target, String name) { Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass()); if (type.isArray() && name.equals("length")) { return TypeDescriptor.valueOf(Integer.TYPE); } PropertyCacheKey cacheKey = new PropertyCacheKey(type, name, target instanceof Class); TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey); if (typeDescriptor == null) { // Attempt to populate the cache entry try { if (canRead(context, target, name) || canWrite(context, target, name)) { typeDescriptor = this.typeDescriptorCache.get(cacheKey); } } catch (AccessException ex) { // Continue with null type descriptor } } return typeDescriptor; }
@Nullable private TypeDescriptor getTypeDescriptor(EvaluationContext context, Object target, String name) { Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass()); if (type.isArray() && name.equals("length")) { return TypeDescriptor.valueOf(Integer.TYPE); } PropertyCacheKey cacheKey = new PropertyCacheKey(type, name, target instanceof Class); TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey); if (typeDescriptor == null) { // Attempt to populate the cache entry try { if (canRead(context, target, name) || canWrite(context, target, name)) { typeDescriptor = this.typeDescriptorCache.get(cacheKey); } } catch (AccessException ex) { // Continue with null type descriptor } } return typeDescriptor; }
assertEquals(3,rpa.read(ctx, t, "field").getValue()); // cached accessor used assertTrue(rpa.canWrite(ctx, t, "property")); rpa.write(ctx, t, "property", "goodbye"); rpa.write(ctx, t, "property", "goodbye"); // cached accessor used assertTrue(rpa.canWrite(ctx, t, "field")); rpa.write(ctx, t, "field", 12); rpa.write(ctx, t, "field", 12);
@Override public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException { return super.canWrite(context, target, name); }
@Nullable private TypeDescriptor getTypeDescriptor(EvaluationContext context, Object target, String name) { Class<?> type = (target instanceof Class ? (Class<?>) target : target.getClass()); if (type.isArray() && name.equals("length")) { return TypeDescriptor.valueOf(Integer.TYPE); } PropertyCacheKey cacheKey = new PropertyCacheKey(type, name, target instanceof Class); TypeDescriptor typeDescriptor = this.typeDescriptorCache.get(cacheKey); if (typeDescriptor == null) { // Attempt to populate the cache entry try { if (canRead(context, target, name) || canWrite(context, target, name)) { typeDescriptor = this.typeDescriptorCache.get(cacheKey); } } catch (AccessException ex) { // Continue with null type descriptor } } return typeDescriptor; }