@Test void testWrapMerge() throws Exception { Resource original = context.create().resource("/original/path", SAMPLE_PROPERTES); Resource underTest = wrapMerge(original, OTHER_SAMPLE_PROPERTES); assertEquals("/original/path", underTest.getPath()); assertEquals("value2", underTest.getValueMap().get("prop1", String.class)); assertEquals(25, (int)underTest.getValueMap().get("prop2", 0)); assertEquals(55, (int)underTest.getValueMap().get("prop3", 0)); }
public static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap) { Map<String, Object> mergedProperties = new HashMap<>(); mergedProperties.putAll(resource.getValueMap()); mergedProperties.putAll(valueMap); return wrap(resource, new ValueMapDecorator(mergedProperties), resource.getChildren()); }
GraniteUiSyntheticResource extends SyntheticResource { public static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap) { Map<String, Object> mergedProperties = new HashMap<>(); mergedProperties.putAll(resource.getValueMap()); mergedProperties.putAll(valueMap); return wrap(resource, new ValueMapDecorator(mergedProperties), resource.getChildren()); } }
GraniteUiSyntheticResource extends SyntheticResource { public static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap) { Map<String, Object> mergedProperties = new HashMap<>(); mergedProperties.putAll(resource.getValueMap()); mergedProperties.putAll(valueMap); return wrap(resource, new ValueMapDecorator(mergedProperties), resource.getChildren()); } private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      ResourceMetadata resourceMetadata, String resourceType,
      ValueMap props, Iterable<Resource> children); private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      String path,
      String resourceType,
      ValueMap props,
      Iterable<Resource> children); }
GraniteUiSyntheticResource extends SyntheticResource { public static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap) { Map<String, Object> mergedProperties = new HashMap<>(); mergedProperties.putAll(resource.getValueMap()); mergedProperties.putAll(valueMap); return wrap(resource, new ValueMapDecorator(mergedProperties), resource.getChildren()); } private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      ResourceMetadata resourceMetadata, String resourceType,
      ValueMap props, Iterable<Resource> children); private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      String path,
      String resourceType,
      ValueMap props,
      Iterable<Resource> children); @SuppressWarnings({ "unchecked", "null" }) @Override Type adaptTo(Class<Type> type); @Override Iterator<Resource> listChildren(); @Override Iterable<Resource> getChildren(); @Override boolean hasChildren(); @Override Resource getChild(String relPath); static Resource create(@NotNull ResourceResolver resourceResolver, @NotNull ValueMap valueMap); static Resource create(@NotNull ResourceResolver resourceResolver, @Nullable String path, @NotNull String resourceType); static Resource create(@NotNull ResourceResolver resourceResolver, @Nullable String path, @NotNull String resourceType,
      @NotNull ValueMap valueMap); static Resource wrap(@NotNull Resource resource); static Resource wrap(@NotNull Resource resource, @NotNull ValueMap valueMap); static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap); static Resource child(@NotNull Resource parentResource, @NotNull String name, @NotNull String resourceType); static Resource child(@NotNull Resource parentResource, @NotNull String name, @NotNull String resourceType,
      @NotNull ValueMap valueMap); static void copySubtree(@NotNull Resource targetParent, @NotNull Resource source); }
GraniteUiSyntheticResource extends SyntheticResource { public static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap) { Map<String, Object> mergedProperties = new HashMap<>(); mergedProperties.putAll(resource.getValueMap()); mergedProperties.putAll(valueMap); return wrap(resource, new ValueMapDecorator(mergedProperties), resource.getChildren()); } private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      ResourceMetadata resourceMetadata, String resourceType,
      ValueMap props, Iterable<Resource> children); private  GraniteUiSyntheticResource(ResourceResolver resourceResolver,
      String path,
      String resourceType,
      ValueMap props,
      Iterable<Resource> children); @SuppressWarnings({ "unchecked", "null" }) @Override Type adaptTo(Class<Type> type); @Override Iterator<Resource> listChildren(); @Override Iterable<Resource> getChildren(); @Override boolean hasChildren(); @Override Resource getChild(String relPath); static Resource create(@NotNull ResourceResolver resourceResolver, @NotNull ValueMap valueMap); static Resource create(@NotNull ResourceResolver resourceResolver, @Nullable String path, @NotNull String resourceType); static Resource create(@NotNull ResourceResolver resourceResolver, @Nullable String path, @NotNull String resourceType,
      @NotNull ValueMap valueMap); static Resource wrap(@NotNull Resource resource); static Resource wrap(@NotNull Resource resource, @NotNull ValueMap valueMap); static Resource wrapMerge(@NotNull Resource resource, @NotNull ValueMap valueMap); static Resource child(@NotNull Resource parentResource, @NotNull String name, @NotNull String resourceType); static Resource child(@NotNull Resource parentResource, @NotNull String name, @NotNull String resourceType,
      @NotNull ValueMap valueMap); static void copySubtree(@NotNull Resource targetParent, @NotNull Resource source);  }