freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [01/11] incubator-freemarker git commit: (Common Builder API cleanup)
Date Fri, 05 May 2017 21:00:24 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 78a0bddb6 -> 7d61a45d9


(Common Builder API cleanup)


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/7c85a563
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/7c85a563
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/7c85a563

Branch: refs/heads/3
Commit: 7c85a5630976a126911a6b583f3a17b5e36bfcf8
Parents: 78a0bdd
Author: ddekany <ddekany@apache.org>
Authored: Tue Apr 18 13:09:50 2017 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Tue Apr 18 13:09:50 2017 +0200

----------------------------------------------------------------------
 .../core/model/impl/ClassIntrospector.java      | 37 +++++++----
 .../core/model/impl/DefaultObjectWrapper.java   | 67 ++++++++++++--------
 .../DefaultObjectWrapperTCCLSingletonUtil.java  |  4 +-
 .../freemarker/core/util/FluentBuilder.java     | 36 -----------
 .../core/util/ProductWrappingBuilder.java       |  3 +-
 5 files changed, 65 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7c85a563/src/main/java/org/apache/freemarker/core/model/impl/ClassIntrospector.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/ClassIntrospector.java b/src/main/java/org/apache/freemarker/core/model/impl/ClassIntrospector.java
index 2a54618..2159f31 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/ClassIntrospector.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/ClassIntrospector.java
@@ -50,7 +50,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import org.apache.freemarker.core.Version;
 import org.apache.freemarker.core._CoreLogs;
 import org.apache.freemarker.core.util.BugException;
-import org.apache.freemarker.core.util.FluentBuilder;
+import org.apache.freemarker.core.util.CommonBuilder;
 import org.apache.freemarker.core.util._JavaVersions;
 import org.apache.freemarker.core.util._NullArgumentException;
 import org.slf4j.Logger;
@@ -1073,18 +1073,18 @@ class ClassIntrospector {
         }
     }
 
-    static final class Builder extends FluentBuilder<ClassIntrospector, Builder> implements
Cloneable {
+    static final class Builder implements CommonBuilder<ClassIntrospector>, Cloneable
{
 
         private static final Map/*<PropertyAssignments, Reference<ClassIntrospector>>*/
INSTANCE_CACHE = new HashMap();
         private static final ReferenceQueue INSTANCE_CACHE_REF_QUEUE = new ReferenceQueue();
 
         // Properties and their *defaults*:
         private int exposureLevel = DefaultObjectWrapper.EXPOSE_SAFE;
-        private boolean exposureLevelExplicitlySet;
+        private boolean exposureLevelSet;
         private boolean exposeFields;
-        private boolean exposeFieldsExplicitlySet;
+        private boolean exposeFieldsSet;
         private MethodAppearanceFineTuner methodAppearanceFineTuner;
-        private boolean methodAppearanceFineTunerExplicitlySet;
+        private boolean methodAppearanceFineTunerSet;
         private MethodSorter methodSorter;
         // Attention:
         // - This is also used as a cache key, so non-normalized field values should be avoided.
@@ -1151,11 +1151,14 @@ class ClassIntrospector {
             }
 
             this.exposureLevel = exposureLevel;
-            exposureLevelExplicitlySet = true;
+            exposureLevelSet = true;
         }
 
-        public boolean isExposureLevelExplicitlySet() {
-            return exposureLevelExplicitlySet;
+        /**
+         * Tells if the property was explicitly set, as opposed to just holding its default
value.
+         */
+        public boolean isExposureLevelSet() {
+            return exposureLevelSet;
         }
 
         public boolean getExposeFields() {
@@ -1165,11 +1168,14 @@ class ClassIntrospector {
         /** See {@link DefaultObjectWrapper.ExtendableBuilder#setExposeFields(boolean)}.
*/
         public void setExposeFields(boolean exposeFields) {
             this.exposeFields = exposeFields;
-            exposeFieldsExplicitlySet = true;
+            exposeFieldsSet = true;
         }
 
-        public boolean isExposeFieldsExplicitlySet() {
-            return exposeFieldsExplicitlySet;
+        /**
+         * Tells if the property was explicitly set, as opposed to just holding its default
value.
+         */
+        public boolean isExposeFieldsSet() {
+            return exposeFieldsSet;
         }
 
         public MethodAppearanceFineTuner getMethodAppearanceFineTuner() {
@@ -1178,11 +1184,14 @@ class ClassIntrospector {
 
         public void setMethodAppearanceFineTuner(MethodAppearanceFineTuner methodAppearanceFineTuner)
{
             this.methodAppearanceFineTuner = methodAppearanceFineTuner;
-            methodAppearanceFineTunerExplicitlySet = true;
+            methodAppearanceFineTunerSet = true;
         }
 
-        public boolean isMethodAppearanceFineTunerExplicitlySet() {
-            return methodAppearanceFineTunerExplicitlySet;
+        /**
+         * Tells if the property was explicitly set, as opposed to just holding its default
value.
+         */
+        public boolean isMethodAppearanceFineTunerSet() {
+            return methodAppearanceFineTunerSet;
         }
 
         public MethodSorter getMethodSorter() {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7c85a563/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java
b/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java
index d01c902..a20695a 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapper.java
@@ -64,7 +64,7 @@ import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.WrapperTemplateModel;
 import org.apache.freemarker.core.util.BugException;
-import org.apache.freemarker.core.util.FluentBuilder;
+import org.apache.freemarker.core.util.CommonBuilder;
 import org.apache.freemarker.core.util._ClassUtil;
 import org.apache.freemarker.dom.NodeModel;
 import org.slf4j.Logger;
@@ -1326,7 +1326,7 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
      */
     protected abstract static class ExtendableBuilder<
             ProductT extends DefaultObjectWrapper, SelfT extends ExtendableBuilder<ProductT,
SelfT>>
-            extends FluentBuilder<ProductT, SelfT> implements Cloneable {
+            implements CommonBuilder<ProductT>, Cloneable {
 
         private final Version incompatibleImprovements;
 
@@ -1335,15 +1335,15 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
 
         // Properties and their *defaults*:
         private int defaultDateType = TemplateDateModel.UNKNOWN;
-        private boolean defaultDataTypeExplicitlySet;
+        private boolean defaultDataTypeSet;
         private ObjectWrapper outerIdentity;
-        private boolean outerIdentityExplicitlySet;
+        private boolean outerIdentitySet;
         private boolean strict;
-        private boolean strictExplicitlySet;
+        private boolean strictSet;
         private boolean useModelCache;
-        private boolean useModelCacheExplicitlySet;
+        private boolean useModelCacheSet;
         private boolean usePrivateCaches;
-        private boolean usePrivateCachesExplicitlySet;
+        private boolean usePrivateCachesSet;
         // Attention!
         // - As this object is a cache key, non-normalized field values should be avoided.
         // - Fields with default values must be set until the end of the constructor to ensure
that when the lookup happens,
@@ -1395,6 +1395,11 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
             classIntrospectorBuilder = new ClassIntrospector.Builder(incompatibleImprovements);
         }
 
+        @SuppressWarnings("unchecked")
+        protected SelfT self() {
+            return (SelfT) this;
+        }
+
         /**
          * Calculate a content-based hash that could be used when looking up the product
object that {@link #build()}
          * returns from a cache. If you override {@link ExtendableBuilder} and add new fields,
don't forget to take
@@ -1490,7 +1495,7 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
          */
         public void setDefaultDateType(int defaultDateType) {
             this.defaultDateType = defaultDateType;
-            defaultDataTypeExplicitlySet = true;
+            defaultDataTypeSet = true;
         }
 
         /**
@@ -1504,8 +1509,8 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean isDefaultDataTypeExplicitlySet() {
-            return defaultDataTypeExplicitlySet;
+        public boolean isDefaultDateTypeSet() {
+            return defaultDataTypeSet;
         }
 
         /**
@@ -1526,7 +1531,7 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
          */
         public void setOuterIdentity(ObjectWrapper outerIdentity) {
             this.outerIdentity = outerIdentity;
-            outerIdentityExplicitlySet = true;
+            outerIdentitySet = true;
         }
 
         /**
@@ -1540,8 +1545,8 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean isOuterIdentityExplicitlySet() {
-            return outerIdentityExplicitlySet;
+        public boolean isOuterIdentitySet() {
+            return outerIdentitySet;
         }
 
         /**
@@ -1574,7 +1579,7 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
          */
         public void setStrict(boolean strict) {
             this.strict = strict;
-            strictExplicitlySet = true;
+            strictSet = true;
         }
 
         /**
@@ -1588,8 +1593,8 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean isStrictExplicitlySet() {
-            return strictExplicitlySet;
+        public boolean isStrictSet() {
+            return strictSet;
         }
 
         public boolean getUseModelCache() {
@@ -1602,7 +1607,7 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         // [FM3] Remove
         public void setUseModelCache(boolean useModelCache) {
             this.useModelCache = useModelCache;
-            useModelCacheExplicitlySet = true;
+            useModelCacheSet = true;
         }
 
         /**
@@ -1617,8 +1622,8 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean isUseModelCacheExplicitlySet() {
-            return useModelCacheExplicitlySet;
+        public boolean isUseModelCacheSet() {
+            return useModelCacheSet;
         }
 
         /**
@@ -1634,14 +1639,14 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
          * */
         public void setUsePrivateCaches(boolean usePrivateCaches) {
             this.usePrivateCaches = usePrivateCaches;
-            usePrivateCachesExplicitlySet = true;
+            usePrivateCachesSet = true;
         }
 
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean isUsePrivateCachesExplicitlySet() {
-            return usePrivateCachesExplicitlySet;
+        public boolean isUsePrivateCachesSet() {
+            return usePrivateCachesSet;
         }
 
         /**
@@ -1673,8 +1678,8 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
         /**
          * Tells if the property was explicitly set, as opposed to just holding its default
value.
          */
-        public boolean setExposureLevelExplicitlySet() {
-            return classIntrospectorBuilder.isExposureLevelExplicitlySet();
+        public boolean setExposureLevelSet() {
+            return classIntrospectorBuilder.isExposureLevelSet();
         }
 
         /**
@@ -1706,8 +1711,11 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
             return self();
         }
 
-        public boolean isExposeFieldsExplicitlySet() {
-            return classIntrospectorBuilder.isExposeFieldsExplicitlySet();
+        /**
+         * Tells if the property was explicitly set, as opposed to just holding its default
value.
+         */
+        public boolean isExposeFieldsSet() {
+            return classIntrospectorBuilder.isExposeFieldsSet();
         }
 
         /**
@@ -1735,8 +1743,11 @@ public class DefaultObjectWrapper implements RichObjectWrapper {
             return self();
         }
 
-        public boolean isMethodAppearanceFineTunerExplicitlySet() {
-            return classIntrospectorBuilder.isMethodAppearanceFineTunerExplicitlySet();
+        /**
+         * Tells if the property was explicitly set, as opposed to just holding its default
value.
+         */
+        public boolean isMethodAppearanceFineTunerSet() {
+            return classIntrospectorBuilder.isMethodAppearanceFineTunerSet();
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7c85a563/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTCCLSingletonUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTCCLSingletonUtil.java
b/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTCCLSingletonUtil.java
index 231c20a..f5b617d 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTCCLSingletonUtil.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/DefaultObjectWrapperTCCLSingletonUtil.java
@@ -26,7 +26,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.freemarker.core.util.FluentBuilder;
+import org.apache.freemarker.core.util.CommonBuilder;
 
 /**
  * Utility method for caching {@link DefaultObjectWrapper} (and subclasses) sigletons per
Thread Context Class
@@ -119,7 +119,7 @@ final class DefaultObjectWrapperTCCLSingletonUtil {
     /**
      * For internal use only; don't depend on this, there's no backward compatibility guarantee
at all!
      * Used when the builder delegates the product creation to something else (typically,
an instance cache). Calling
-     * {@link FluentBuilder#build()} would be infinite recursion in such cases.
+     * {@link CommonBuilder#build()} would be infinite recursion in such cases.
      */
     public interface _ConstructorInvoker<ProductT, BuilderT> {
 

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7c85a563/src/main/java/org/apache/freemarker/core/util/FluentBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/FluentBuilder.java b/src/main/java/org/apache/freemarker/core/util/FluentBuilder.java
deleted file mode 100644
index a5e1e5a..0000000
--- a/src/main/java/org/apache/freemarker/core/util/FluentBuilder.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.freemarker.core.util;
-
-/**
- * Common superclass for implementing {@link CommonBuilder}; adds helper method to implement
a fluent API.
- */
-public abstract class FluentBuilder<ProductT, SelfT extends FluentBuilder<ProductT,
SelfT>>
-        implements CommonBuilder<ProductT> {
-
-    @Override
-    public abstract ProductT build();
-
-    @SuppressWarnings("unchecked")
-    protected SelfT self() {
-        return (SelfT) this;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7c85a563/src/main/java/org/apache/freemarker/core/util/ProductWrappingBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/ProductWrappingBuilder.java b/src/main/java/org/apache/freemarker/core/util/ProductWrappingBuilder.java
index 7bd98f4..4b76dc5 100644
--- a/src/main/java/org/apache/freemarker/core/util/ProductWrappingBuilder.java
+++ b/src/main/java/org/apache/freemarker/core/util/ProductWrappingBuilder.java
@@ -22,8 +22,7 @@ package org.apache.freemarker.core.util;
 /**
  * A builder that encloses an already built product. {@link #build()} will always return
the same product object.
  */
-public class ProductWrappingBuilder<ProductT, SelfT extends ProductWrappingBuilder<ProductT,
SelfT>>
-        extends FluentBuilder<ProductT, SelfT> {
+public class ProductWrappingBuilder<ProductT> implements CommonBuilder<ProductT>
{
 
     private final ProductT product;
 


Mime
View raw message