Repository: incubator-freemarker Updated Branches: refs/heads/3 ea2a285c9 -> 658aec12f
Renamed getCustomSettingsSnapshot to getCustomSettings; in most usages it doesn't mater that it's a snapshot, and the JavaDoc describes that. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/658aec12 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/658aec12 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/658aec12 Branch: refs/heads/3 Commit: 658aec12f3ac902e994849147311c5bb6073c16f Parents: ea2a285 Author: ddekany <[email protected]> Authored: Sat Jun 3 13:56:45 2017 +0200 Committer: ddekany <[email protected]> Committed: Sat Jun 3 13:56:45 2017 +0200 ---------------------------------------------------------------------- .../freemarker/core/CustomSettingTest.java | 46 ++++++++++---------- .../TemplateConfigurationFactoryTest.java | 2 +- .../apache/freemarker/core/Configuration.java | 4 +- .../org/apache/freemarker/core/Environment.java | 2 +- .../core/MutableProcessingConfiguration.java | 4 +- .../core/ProcessingConfiguration.java | 8 ++-- .../org/apache/freemarker/core/Template.java | 8 ++-- .../freemarker/core/TemplateConfiguration.java | 8 ++-- 8 files changed, 41 insertions(+), 41 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomSettingTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomSettingTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomSettingTest.java index 51debd3..9a56566 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomSettingTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/CustomSettingTest.java @@ -59,8 +59,8 @@ public class CustomSettingTest { } private void testMutableProcessingConfiguration(MutableProcessingConfiguration<?> mpc) { - assertTrue(mpc.getCustomSettingsSnapshot(true).isEmpty()); - assertTrue(mpc.getCustomSettingsSnapshot(false).isEmpty()); + assertTrue(mpc.getCustomSettings(true).isEmpty()); + assertTrue(mpc.getCustomSettings(false).isEmpty()); testMissingCustomSettingAccess(mpc, KEY_1); mpc.setCustomSetting(KEY_1, VALUE_1); @@ -69,24 +69,24 @@ public class CustomSettingTest { assertSame(VALUE_1, mpc.getCustomSetting(KEY_1)); assertSame(VALUE_2, mpc.getCustomSetting(KEY_2)); testMissingCustomSettingAccess(mpc, KEY_3); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1, KEY_2, VALUE_2), mpc.getCustomSettingsSnapshot(true)); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1, KEY_2, VALUE_2), mpc.getCustomSettingsSnapshot(false)); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1, KEY_2, VALUE_2), mpc.getCustomSettings(true)); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1, KEY_2, VALUE_2), mpc.getCustomSettings(false)); assertSame(VALUE_2, mpc.getCustomSetting(KEY_2, "default")); mpc.unsetCustomSetting(KEY_2); assertEquals("default", mpc.getCustomSetting(KEY_2, "default")); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1), mpc.getCustomSettingsSnapshot(true)); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1), mpc.getCustomSettingsSnapshot(false)); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1), mpc.getCustomSettings(true)); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1), mpc.getCustomSettings(false)); mpc.unsetAllCustomSettings(); - assertTrue(mpc.getCustomSettingsSnapshot(true).isEmpty()); + assertTrue(mpc.getCustomSettings(true).isEmpty()); testCustomSettingsSnapshotIsUnmodifiable(mpc); mpc.setCustomSetting(KEY_1, VALUE_1); testCustomSettingsSnapshotIsUnmodifiable(mpc); // Test no aliasing - Map<Serializable, Object> attrMap1 = mpc.getCustomSettingsSnapshot(false); + Map<Serializable, Object> attrMap1 = mpc.getCustomSettings(false); mpc.setCustomSetting(KEY_2, VALUE_2); assertNull(attrMap1.get(KEY_2)); @@ -95,7 +95,7 @@ public class CustomSettingTest { mpc.setCustomSettings(ImmutableMap.of(KEY_2, VALUE_2, KEY_3, VALUE_3)); assertEquals( ImmutableMap.of(KEY_1, VALUE_1, KEY_2, VALUE_2, KEY_3, VALUE_3), - mpc.getCustomSettingsSnapshot(false)); + mpc.getCustomSettings(false)); try { mpc.setCustomSetting(KEY_1, MISSING_VALUE_MARKER); @@ -117,7 +117,7 @@ public class CustomSettingTest { private void testCustomSettingsSnapshotIsUnmodifiable(ProcessingConfiguration pc) { for (boolean includeInherited : new boolean[] { false, true }) { - Map<Serializable, Object> map = pc.getCustomSettingsSnapshot(includeInherited); + Map<Serializable, Object> map = pc.getCustomSettings(includeInherited); try { map.put("aNewKey", 123); fail(); @@ -149,7 +149,7 @@ public class CustomSettingTest { + "}>", new Configuration.Builder(Configuration.VERSION_3_0_0).build()); - assertEquals(ImmutableSet.of(KEY_1, KEY_2), t.getCustomSettingsSnapshot(true).keySet()); + assertEquals(ImmutableSet.of(KEY_1, KEY_2), t.getCustomSettings(true).keySet()); assertEquals( ImmutableList.<Object>of("s", BigDecimal.valueOf(2), Boolean.TRUE, ImmutableMap.of("a", "A")), t.getCustomSetting(KEY_1)); @@ -173,7 +173,7 @@ public class CustomSettingTest { tcb.build()); assertEquals(ImmutableMap.of(KEY_1, "a", KEY_2, "b", KEY_3, "c", KEY_4, VALUE_4), - t.getCustomSettingsSnapshot(true)); + t.getCustomSettings(true)); assertEquals("a", t.getCustomSetting(KEY_1)); assertEquals("b", t.getCustomSetting(KEY_2)); assertEquals("c", t.getCustomSetting(KEY_3)); // Has overridden TC attribute @@ -192,7 +192,7 @@ public class CustomSettingTest { new Configuration.Builder(Configuration.VERSION_3_0_0).build(), tcb.build()); - assertEquals(ImmutableSet.of(KEY_3, KEY_4), t.getCustomSettingsSnapshot(true).keySet()); + assertEquals(ImmutableSet.of(KEY_3, KEY_4), t.getCustomSettings(true).keySet()); assertEquals(VALUE_3, t.getCustomSetting(KEY_3)); assertEquals(VALUE_4, t.getCustomSetting(KEY_4)); @@ -210,8 +210,8 @@ public class CustomSettingTest { assertEquals(VALUE_1, t.getCustomSetting(KEY_1)); assertEquals("default", t.getCustomSetting(KEY_2, "default")); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1), t.getCustomSettingsSnapshot(true)); - assertTrue(t.getCustomSettingsSnapshot(false).isEmpty()); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1), t.getCustomSettings(true)); + assertTrue(t.getCustomSettings(false).isEmpty()); testMissingCustomSettingAccess(t); testCustomSettingsSnapshotIsUnmodifiable(t); @@ -227,8 +227,8 @@ public class CustomSettingTest { assertEquals(VALUE_1, t.getCustomSetting(KEY_1)); assertEquals("v2", t.getCustomSetting("k2")); - assertEquals(ImmutableMap.of(KEY_1, VALUE_1, "k2", "v2"), t.getCustomSettingsSnapshot(true)); - assertEquals(ImmutableMap.of("k2", "v2"), t.getCustomSettingsSnapshot(false)); + assertEquals(ImmutableMap.of(KEY_1, VALUE_1, "k2", "v2"), t.getCustomSettings(true)); + assertEquals(ImmutableMap.of("k2", "v2"), t.getCustomSettings(false)); testMissingCustomSettingAccess(t); testCustomSettingsSnapshotIsUnmodifiable(t); @@ -247,9 +247,9 @@ public class CustomSettingTest { assertEquals(VALUE_3, t.getCustomSetting(KEY_3)); assertEquals(ImmutableMap.of(KEY_1, VALUE_1, "k2", "v2", KEY_3, VALUE_3), - t.getCustomSettingsSnapshot(true)); + t.getCustomSettings(true)); assertEquals(ImmutableMap.of("k2", "v2", KEY_3, VALUE_3), - t.getCustomSettingsSnapshot(false)); + t.getCustomSettings(false)); testMissingCustomSettingAccess(t); testCustomSettingsSnapshotIsUnmodifiable(t); @@ -260,9 +260,9 @@ public class CustomSettingTest { assertEquals("v2", env.getCustomSetting("k2")); assertEquals(VALUE_3, env.getCustomSetting(KEY_3)); assertEquals(ImmutableMap.of(KEY_1, VALUE_1, "k2", "v2", KEY_3, VALUE_3), - env.getCustomSettingsSnapshot(true)); + env.getCustomSettings(true)); assertEquals(Collections.emptyMap(), - env.getCustomSettingsSnapshot(false)); + env.getCustomSettings(false)); env.setCustomSetting(KEY_4, VALUE_4); assertEquals(VALUE_1, env.getCustomSetting(KEY_1)); @@ -270,9 +270,9 @@ public class CustomSettingTest { assertEquals(VALUE_3, env.getCustomSetting(KEY_3)); assertEquals(VALUE_4, env.getCustomSetting(KEY_4)); assertEquals(ImmutableMap.of(KEY_1, VALUE_1, "k2", "v2", KEY_3, VALUE_3, KEY_4, VALUE_4), - env.getCustomSettingsSnapshot(true)); + env.getCustomSettings(true)); assertEquals(ImmutableMap.of(KEY_4, VALUE_4), - env.getCustomSettingsSnapshot(false)); + env.getCustomSettings(false)); testMissingCustomSettingAccess(env); testCustomSettingsSnapshotIsUnmodifiable(env); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java ---------------------------------------------------------------------- diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java index c0910d3..8bf72dd 100644 --- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java +++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/templateresolver/TemplateConfigurationFactoryTest.java @@ -167,7 +167,7 @@ public class TemplateConfigurationFactoryTest { private void assertApplicable(TemplateConfigurationFactory tcf, String sourceName, TemplateConfiguration... expectedTCs) throws IOException, TemplateConfigurationFactoryException { TemplateConfiguration mergedTC = tcf.get(sourceName, DummyTemplateLoadingSource.INSTANCE); - List<Serializable> mergedTCAttNames = new ArrayList<>(mergedTC.getCustomSettingsSnapshot(false).keySet()); + List<Serializable> mergedTCAttNames = new ArrayList<>(mergedTC.getCustomSettings(false).keySet()); for (TemplateConfiguration expectedTC : expectedTCs) { Integer tcId = (Integer) expectedTC.getCustomSetting("id"); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java index 9076391..ef764c4 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Configuration.java @@ -437,7 +437,7 @@ public final class Configuration autoIncludes = builder.getAutoIncludes(); lazyImports = builder.getLazyImports(); lazyAutoImports = builder.getLazyAutoImports(); - customSettings = builder.getCustomSettingsSnapshot(false); + customSettings = builder.getCustomSettings(false); } private <SelfT extends ExtendableBuilder<SelfT>> void wrapAndPutSharedVariables( @@ -1180,7 +1180,7 @@ public final class Configuration * Because {@link Configuration} has on parent, the {@code includeInherited} parameter is ignored. */ @Override - public Map<Serializable, Object> getCustomSettingsSnapshot(boolean includeInherited) { + public Map<Serializable, Object> getCustomSettings(boolean includeInherited) { return customSettings; } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java index 869b72d..d4211b6 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Environment.java @@ -1099,7 +1099,7 @@ public final class Environment extends MutableProcessingConfiguration<Environmen @Override protected void collectDefaultCustomSettingsSnapshot(Map<Serializable, Object> target) { - target.putAll(getMainTemplate().getCustomSettingsSnapshot(true)); + target.putAll(getMainTemplate().getCustomSettings(true)); } /* http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java index bbdbecf..ff50bd8 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableProcessingConfiguration.java @@ -2199,7 +2199,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces } @Override - public Map<Serializable, Object> getCustomSettingsSnapshot(boolean includeInherited) { + public Map<Serializable, Object> getCustomSettings(boolean includeInherited) { if (includeInherited) { LinkedHashMap<Serializable, Object> result = new LinkedHashMap<>(); collectDefaultCustomSettingsSnapshot(result); @@ -2217,7 +2217,7 @@ public abstract class MutableProcessingConfiguration<SelfT extends MutableProces } /** - * Called from {@link #getCustomSettingsSnapshot(boolean)}, adds the default (such as inherited) custom settings + * Called from {@link #getCustomSettings(boolean)}, adds the default (such as inherited) custom settings * to the argument {@link Map}. */ protected abstract void collectDefaultCustomSettingsSnapshot(Map<Serializable, Object> target); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java index 6814967..a9c4584 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ProcessingConfiguration.java @@ -740,8 +740,8 @@ public interface ProcessingConfiguration { boolean isCustomSettingSet(Serializable key); /** - * Collects all {@linkplain #getCustomSetting(Serializable)} custom settings} into a {@link Map}; mostly useful for - * debugging and tooling, and is possibly too slow to call very frequently. + * Collects all {@linkplain #getCustomSetting(Serializable)} custom settings} into a {@link Map} (which is a + * snapshot); mostly useful for debugging and tooling, and is possibly too slow to call very frequently. * * @param includeInherited * If {@code false}, only the custom settings set in this {@link ProcessingConfiguration} will be @@ -750,10 +750,10 @@ public interface ProcessingConfiguration { * #getCustomSetting(Serializable)}. * * @return An unmodifiable and unchanging {@link Map}; not {@code null}. The object identity of keys and values of - * this {@link Map} will not change when custom settings are set/unset later (hence it's a snapshot). But, if + * this {@link Map} will not change when custom settings are set/unset later (it's a snapshot). But, if * a key or value objects are themselves mutable objects, FreeMarker can't prevent their content from changing. * You shouldn't change the content of those objects. */ - Map<Serializable, Object> getCustomSettingsSnapshot(boolean includeInherited); + Map<Serializable, Object> getCustomSettings(boolean includeInherited); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java index 8b8db5e..ab9cc71 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java @@ -1068,7 +1068,7 @@ public class Template implements ProcessingConfiguration, CustomStateScope { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Map<Serializable, Object> getCustomSettingsSnapshot(boolean includeInherited) { + public Map<Serializable, Object> getCustomSettings(boolean includeInherited) { boolean nonInheritedAttrsFinal; Map<? extends Serializable, ? extends Object> nonInheritedAttrs; if (tcAndHeaderCustomSettings != null) { @@ -1078,14 +1078,14 @@ public class Template implements ProcessingConfiguration, CustomStateScope { nonInheritedAttrs = headerCustomSettings; nonInheritedAttrsFinal = writeProtected; } else if (tCfg != null) { - nonInheritedAttrs = tCfg.getCustomSettingsSnapshot(false); + nonInheritedAttrs = tCfg.getCustomSettings(false); nonInheritedAttrsFinal = true; } else { nonInheritedAttrs = Collections.emptyMap(); nonInheritedAttrsFinal = true; } - Map<Serializable, Object> inheritedAttrs = includeInherited ? cfg.getCustomSettingsSnapshot(true) + Map<Serializable, Object> inheritedAttrs = includeInherited ? cfg.getCustomSettings(true) : Collections.<Serializable, Object>emptyMap(); LinkedHashMap<Serializable, Object> mergedAttrs; @@ -1156,7 +1156,7 @@ public class Template implements ProcessingConfiguration, CustomStateScope { headerCustomSettings.put(attName, attValue); if (tCfg != null) { - Map<Serializable, Object> tcCustAttrs = tCfg.getCustomSettingsSnapshot(false); + Map<Serializable, Object> tcCustAttrs = tCfg.getCustomSettings(false); if (!tcCustAttrs.isEmpty()) { if (tcAndHeaderCustomSettings == null) { tcAndHeaderCustomSettings = new LinkedHashMap<>(tcCustAttrs); http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/658aec12/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java ---------------------------------------------------------------------- diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java index ca37fa6..6c837e4 100644 --- a/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java +++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TemplateConfiguration.java @@ -124,7 +124,7 @@ public final class TemplateConfiguration implements ParsingAndProcessingConfigur lazyImports = builder.isLazyImportsSet() ? builder.getLazyImports() : null; lazyAutoImportsSet = builder.isLazyAutoImportsSet(); lazyAutoImports = lazyAutoImportsSet ? builder.getLazyAutoImports() : null; - customSettings = builder.getCustomSettingsSnapshot(false); + customSettings = builder.getCustomSettings(false); templateLanguage = builder.isTemplateLanguageSet() ? builder.getTemplateLanguage() : null; tagSyntax = builder.isTagSyntaxSet() ? builder.getTagSyntax() : null; @@ -634,7 +634,7 @@ public final class TemplateConfiguration implements ParsingAndProcessingConfigur * Note that the {@code includeInherited} has no effect here, as {@link TemplateConfiguration}-s has no parent. */ @Override - public Map<Serializable, Object> getCustomSettingsSnapshot(boolean includeInherited) { + public Map<Serializable, Object> getCustomSettings(boolean includeInherited) { return customSettings; } @@ -935,8 +935,8 @@ public final class TemplateConfiguration implements ParsingAndProcessingConfigur } setCustomSettingsMap(mergeMaps( - getCustomSettingsSnapshot(false), - tc.getCustomSettingsSnapshot(false), + getCustomSettings(false), + tc.getCustomSettings(false), true)); }
