@Test public void testMerge() { DescriptorRegistry registry = new DescriptorRegistry(); CacheDescriptor desc1 = new CacheDescriptor(); desc1.name = NAME; desc1.setTTL(Long.valueOf(123)); desc1.options = new HashMap<>(); desc1.options.put("foo", "foovalue"); desc1.options.put("bar", "barvalue"); registry.register(COMPONENT, XP, desc1); CacheDescriptor desc2 = new CacheDescriptor(); desc2.name = NAME; desc2.setTTL(Long.valueOf(456)); desc2.options = new HashMap<>(); desc2.options.put("foo", "foovalue2"); registry.register(COMPONENT, XP, desc2); CacheDescriptor desc = registry.getDescriptor(COMPONENT, XP, NAME); assertEquals(456, desc.getTTL()); HashMap<String, Serializable> map = new HashMap<>(); map.put("foo", "foovalue2"); map.put("bar", "barvalue"); assertEquals(map, desc.options); }
@Override public Descriptor merge(Descriptor o) { CacheDescriptor other = (CacheDescriptor) o; CacheDescriptor merged = new CacheDescriptor(); merged.name = name; merged.remove = other.remove; merged.ttl = other.ttl != null ? other.ttl : ttl; merged.klass = other.klass != null ? other.klass : klass; merged.options.putAll(options); merged.options.putAll(other.options); return merged; }
CacheDescriptor implements Descriptor { @Override public Descriptor merge(Descriptor o) { CacheDescriptor other = (CacheDescriptor) o; CacheDescriptor merged = new CacheDescriptor(); merged.name = name; merged.remove = other.remove; merged.ttl = other.ttl != null ? other.ttl : ttl; merged.klass = other.klass != null ? other.klass : klass; merged.options.putAll(options); merged.options.putAll(other.options); return merged; } }
CacheDescriptor implements Descriptor { @Override public Descriptor merge(Descriptor o) { CacheDescriptor other = (CacheDescriptor) o; CacheDescriptor merged = new CacheDescriptor(); merged.name = name; merged.remove = other.remove; merged.ttl = other.ttl != null ? other.ttl : ttl; merged.klass = other.klass != null ? other.klass : klass; merged.options.putAll(options); merged.options.putAll(other.options); return merged; }  }
CacheDescriptor implements Descriptor { @Override public Descriptor merge(Descriptor o) { CacheDescriptor other = (CacheDescriptor) o; CacheDescriptor merged = new CacheDescriptor(); merged.name = name; merged.remove = other.remove; merged.ttl = other.ttl != null ? other.ttl : ttl; merged.klass = other.klass != null ? other.klass : klass; merged.options.putAll(options); merged.options.putAll(other.options); return merged; }  @Override String getId(); long getTTL(); void setTTL(Long value); @Override Descriptor merge(Descriptor o); @Override boolean doesRemove(); }
CacheDescriptor implements Descriptor { @Override public Descriptor merge(Descriptor o) { CacheDescriptor other = (CacheDescriptor) o; CacheDescriptor merged = new CacheDescriptor(); merged.name = name; merged.remove = other.remove; merged.ttl = other.ttl != null ? other.ttl : ttl; merged.klass = other.klass != null ? other.klass : klass; merged.options.putAll(options); merged.options.putAll(other.options); return merged; }  @Override String getId(); long getTTL(); void setTTL(Long value); @Override Descriptor merge(Descriptor o); @Override boolean doesRemove(); static final long DEFAULT_TTL; static final long DEFAULT_MAX_SIZE; static final String OPTION_MAX_SIZE; static final String OPTION_CONCURRENCY_LEVEL; @XNode("@name")
    public String name; @XNode("@remove")
    public boolean remove; @XNodeMap(value = "option", key = "@name", type = HashMap.class, componentType = String.class)
    public Map<String, String> options; }