Ejemplo n.º 1
0
 public void setValue(Object value) {
   if (value instanceof ValueHolder) {
     this.valueHolder = (ValueHolder) value;
   } else {
     createValueHolder();
     valueHolder.value = value;
     setLocalValueSet(true);
   }
 }
Ejemplo n.º 2
0
 @Override
 public boolean remove(final String key, final String value) throws CacheAccessException {
   this.checkFailingKey(key);
   final ValueHolder<String> currentValue = this.entries.get(key);
   if (currentValue == null || !currentValue.value().equals(value)) {
     return false;
   }
   this.entries.remove(key);
   return true;
 }
Ejemplo n.º 3
0
 @Override
 public boolean replace(final String key, final String oldValue, final String newValue)
     throws CacheAccessException {
   this.checkFailingKey(key);
   final ValueHolder<String> currentValue = this.entries.get(key);
   if (currentValue != null && currentValue.value().equals(oldValue)) {
     this.entries.put(key, new FakeValueHolder(newValue));
     return true;
   }
   return false;
 }
Ejemplo n.º 4
0
  @Test
  public void testNoCopyCache() {
    cacheManager.addCache(
        new Cache(
            new CacheConfiguration()
                .name(NO_COPY_CACHE)
                .persistence(new PersistenceConfiguration().strategy(strategy))));

    Cache cache = cacheManager.getCache(NO_COPY_CACHE);
    ValueHolder valueHolder = new ValueHolder("value");
    String key = "key";
    Element element = new Element(key, valueHolder, true);
    cache.put(element);

    String otherValue = "otherValue";
    valueHolder.value = otherValue;

    Element cacheContent = cache.get(key);
    assertThat(cacheContent, sameInstance(element));
    assertThat(((ValueHolder) cacheContent.getObjectValue()).value, is(otherValue));
  }
Ejemplo n.º 5
0
 private ToStringHelper addHolder(String name, @Nullable Object value) {
   ValueHolder valueHolder = addHolder();
   valueHolder.value = value;
   valueHolder.name = checkNotNull(name);
   return this;
 }
Ejemplo n.º 6
0
 private ToStringHelper addHolder(@Nullable Object value) {
   ValueHolder valueHolder = addHolder();
   valueHolder.value = value;
   return this;
 }