@Test public void testAttributeMapping() { Resource given = context.create().resource("/foo/bar", "mjmlWidth", "100px", "mjmlBackgroundColor", "red", "mjmlContainerBackgroundColor", "yellow"); Map<String, String> actual = new AttributeMapping(given) .with("width") .with("background-color") .with("container-background-color") .with("background-url") .getAttributes(); assertEquals("100px", actual.get("width")); assertEquals("red", actual.get("background-color")); assertEquals("yellow", actual.get("container-background-color")); assertNull(actual.get("background-url")); }
public AttributeMapping(@Nonnull Resource self) { resourceProperties = self.getValueMap(); policyProperties = Optional.ofNullable(self.getResourceResolver().adaptTo(ContentPolicyManager.class)) .map(contentPolicyManager -> contentPolicyManager.getPolicy(self)) .map(ContentPolicy::getProperties) .orElseGet(() -> new ValueMapDecorator(Collections.emptyMap())); }
AttributeMapping { public AttributeMapping(@Nonnull Resource self) { resourceProperties = self.getValueMap(); policyProperties = Optional.ofNullable(self.getResourceResolver().adaptTo(ContentPolicyManager.class)) .map(contentPolicyManager -> contentPolicyManager.getPolicy(self)) .map(ContentPolicy::getProperties) .orElseGet(() -> new ValueMapDecorator(Collections.emptyMap())); } }
AttributeMapping { public AttributeMapping(@Nonnull Resource self) { resourceProperties = self.getValueMap(); policyProperties = Optional.ofNullable(self.getResourceResolver().adaptTo(ContentPolicyManager.class)) .map(contentPolicyManager -> contentPolicyManager.getPolicy(self)) .map(ContentPolicy::getProperties) .orElseGet(() -> new ValueMapDecorator(Collections.emptyMap())); } AttributeMapping(@Nonnull Resource self); }
AttributeMapping { public AttributeMapping(@Nonnull Resource self) { resourceProperties = self.getValueMap(); policyProperties = Optional.ofNullable(self.getResourceResolver().adaptTo(ContentPolicyManager.class)) .map(contentPolicyManager -> contentPolicyManager.getPolicy(self)) .map(ContentPolicy::getProperties) .orElseGet(() -> new ValueMapDecorator(Collections.emptyMap())); } AttributeMapping(@Nonnull Resource self); @Nonnull AttributeMapping with(@Nonnull String name); @Nonnull AttributeMapping with(@Nonnull String name, @Nullable String defaultValue); @Nonnull Map<String, String> getAttributes(); static void putNotBlank(@Nonnull Map<String, String> target, @Nonnull String key, CharSequence value); }
AttributeMapping { public AttributeMapping(@Nonnull Resource self) { resourceProperties = self.getValueMap(); policyProperties = Optional.ofNullable(self.getResourceResolver().adaptTo(ContentPolicyManager.class)) .map(contentPolicyManager -> contentPolicyManager.getPolicy(self)) .map(ContentPolicy::getProperties) .orElseGet(() -> new ValueMapDecorator(Collections.emptyMap())); } AttributeMapping(@Nonnull Resource self); @Nonnull AttributeMapping with(@Nonnull String name); @Nonnull AttributeMapping with(@Nonnull String name, @Nullable String defaultValue); @Nonnull Map<String, String> getAttributes(); static void putNotBlank(@Nonnull Map<String, String> target, @Nonnull String key, CharSequence value);  }