Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2014 Attila Szegedi, Daniel Dekany, Jonathan Revusky
   * 
   * Licensed 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 freemarker.ext.beans;
 
Holds BeansWrapper configuration settings and defines their defaults. You will not use this abstract class directly, but concrete subclasses like BeansWrapperBuilder and freemarker.template.DefaultObjectWrapperBuilder. Unless, you are developing a builder for a custom BeansWrapper subclass.

This class is designed so that its instances can be used as lookup keys in a singleton cache. This is also why this class defines the configuration setting defaults for BeansWrapper, instead of leaving that to BeansWrapper itself. (Because, the default values influence the lookup key, and the singleton needs to be looked up without creating a BeansWrapper instance.) However, because instances are mutable, you should deep-clone it with clone(boolean) before using it as cache key.

Since:
2.3.21
 
 public abstract class BeansWrapperConfiguration implements Cloneable {
 
     private final Version incompatibleImprovements;
     
     
     // Properties and their *defaults*:
     private boolean simpleMapWrapper = false;
     private int defaultDateType = .;
     private ObjectWrapper outerIdentity = null;
     private boolean strict = false;
     private boolean useModelCache = false;
     // 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,
     //   there will be no unset fields.
     // - If you add a new field, review all methods in this class
     
    

Parameters:
incompatibleImprovements See the corresponding parameter of BeansWrapper.(freemarker.template.Version). Not null. Note that the version will be normalized to the lowest version where the same incompatible BeansWrapper improvements were already present, so for the returned instance getIncompatibleImprovements() might returns a lower version than what you have specified here.
isIncompImprsAlreadyNormalized Tells if the incompatibleImprovements parameter contains an already normalized value. This parameter meant to be true when the class that extends BeansWrapper needs to add additional breaking versions over those of BeansWrapper. Thus, if this parameter is true, the versions where BeansWrapper had breaking changes must be already factored into the incompatibleImprovements parameter value, as no more normalization will happen. (You can use BeansWrapper.normalizeIncompatibleImprovementsVersion(freemarker.template.Version) to discover those.)
Since:
2.3.22
 
     protected BeansWrapperConfiguration(Version incompatibleImprovementsboolean isIncompImprsAlreadyNormalized) {
         _TemplateAPI.checkVersionNotNullAndSupported(incompatibleImprovements);
         
         incompatibleImprovements = isIncompImprsAlreadyNormalized
                 ? incompatibleImprovements
                 : BeansWrapper.normalizeIncompatibleImprovementsVersion(incompatibleImprovements);
         this. = incompatibleImprovements;
         
          = new ClassIntrospectorBuilder(incompatibleImprovements);
     }
    
    
Same as BeansWrapperConfiguration(Version, false).
 
     protected BeansWrapperConfiguration(Version incompatibleImprovements) {
         this(incompatibleImprovementsfalse);
     }
 
     public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + .hashCode();
         result = prime * result + ( ? 1231 : 1237);
         result = prime * result + ;
         result = prime * result + ( != null ? .hashCode() : 0);
         result = prime * result + ( ? 1231 : 1237);
         result = prime * result + ( ? 1231 : 1237);
        result = prime * result + .hashCode();
        return result;
    }

    
Two BeansWrapperConfiguration-s are equal exactly if their classes are identical (==), and their field values are equal.
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (getClass() != obj.getClass()) return false;
        BeansWrapperConfiguration other = (BeansWrapperConfigurationobj;
        
        if (!.equals(other.incompatibleImprovements)) return false;
        if ( != other.simpleMapWrapperreturn false;
        if ( != other.defaultDateTypereturn false;
        if ( != other.outerIdentityreturn false;
        if ( != other.strictreturn false;
        if ( != other.useModelCachereturn false;
        if (!.equals(other.classIntrospectorFactory)) return false;
        
        return true;
    }
    
    protected Object clone(boolean deepCloneKey) {
        try {
            BeansWrapperConfiguration clone = (BeansWrapperConfigurationsuper.clone();
            if (deepCloneKey) {
                clone.classIntrospectorFactory
                        = (ClassIntrospectorBuilder.clone();
            }
            return clone;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException("Failed to clone BeansWrapperConfiguration"e);
        }
    }
    
    public boolean isSimpleMapWrapper() {
        return ;
    }

    
    public void setSimpleMapWrapper(boolean simpleMapWrapper) {
        this. = simpleMapWrapper;
    }
    public int getDefaultDateType() {
        return ;
    }

    
    public void setDefaultDateType(int defaultDateType) {
        this. = defaultDateType;
    }
    public ObjectWrapper getOuterIdentity() {
        return ;
    }

    
See BeansWrapper.setOuterIdentity(freemarker.template.ObjectWrapper), except here the default is null that means the freemarker.template.ObjectWrapper that you will set up with this BeansWrapperBuilder object.
    public void setOuterIdentity(ObjectWrapper outerIdentity) {
        this. = outerIdentity;
    }
    public boolean isStrict() {
        return ;
    }

    
    public void setStrict(boolean strict) {
        this. = strict;
    }
    public boolean getUseModelCache() {
        return ;
    }

    
See BeansWrapper.setUseCache(boolean) (it means the same).
    public void setUseModelCache(boolean useModelCache) {
        this. = useModelCache;
    }
        return ;
    }
    
    public int getExposureLevel() {
    }

    
    public void setExposureLevel(int exposureLevel) {
        .setExposureLevel(exposureLevel);
    }
    public boolean getExposeFields() {
        return .getExposeFields();
    }

    
    public void setExposeFields(boolean exposeFields) {
        .setExposeFields(exposeFields);
    }
    }

    
See BeansWrapper.setMethodAppearanceFineTuner(freemarker.ext.beans.MethodAppearanceFineTuner); additionally, note that currently setting this to non-null will disable class introspection cache sharing, unless the value implements SingletonCustomizer.
    public void setMethodAppearanceFineTuner(MethodAppearanceFineTuner methodAppearanceFineTuner) {
        .setMethodAppearanceFineTuner(methodAppearanceFineTuner);
    }
        return .getMethodSorter();
    }
    void setMethodSorter(MethodSorter methodSorter) {
        .setMethodSorter(methodSorter);
    }
 
New to GrepCode? Check out our FAQ X