Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.ser.impl;
  
  import java.util.*;
  
Simple com.fasterxml.jackson.databind.ser.FilterProvider implementation that just stores direct id-to-filter mapping.
 
 public class SimpleFilterProvider
     extends FilterProvider
     implements java.io.Serializable // since 2.1
 {
     // generated for 2.1.0
     private static final long serialVersionUID = -2825494703774121220L;

    
Mappings from ids to filters.
 
     protected final Map<String,BeanPropertyFilter_filtersById;

    
This is the filter we return in case no mapping was found for given id; default is 'null' (in which case caller typically reports an error), but can be set to an explicit filter.
 
     protected BeanPropertyFilter _defaultFilter;

    
Flag that indicates whether request for an unknown filter id should result an exception (default) or not. Note that this is only relevant if no default filter has been configured.
 
     protected boolean _cfgFailOnUnknownId = true;
     
     /*
     /**********************************************************
     /* Life-cycle: constructing, configuring
     /**********************************************************
      */
     
     public SimpleFilterProvider() {
         this(new HashMap<String,BeanPropertyFilter>());
     }

    

Parameters:
mapping Mapping from id to filter; used as is, no copy is made.
 
     public SimpleFilterProvider(Map<String,BeanPropertyFiltermapping) {
          = mapping;
     }
    
    
Method for defining filter to return for "unknown" filters; cases where there is no mapping from given id to an explicit filter.

Parameters:
f Filter to return when no filter is found for given id
 
     {
          = f;
         return this;
     }
 
     public BeanPropertyFilter getDefaultFilter() {
         return ;
     }
     
     public SimpleFilterProvider setFailOnUnknownId(boolean state) {
          = state;
         return this;
     }
 
     public boolean willFailOnUnknownId() {
         return ;
     }
     
     public SimpleFilterProvider addFilter(String idBeanPropertyFilter filter) {
         .put(idfilter);
         return this;
     }
 
     public BeanPropertyFilter removeFilter(String id) {
         return .remove(id);
     }
 
     /*
     /**********************************************************
     /* Public lookup API
     /**********************************************************
      */
     
     @Override
     public BeanPropertyFilter findFilter(Object filterId)
     {
         BeanPropertyFilter f = .get(filterId);
         if (f == null) {
            f = ;
            if (f == null && ) {
                throw new IllegalArgumentException("No filter configured with id '"+filterId+"' (type "
                        +filterId.getClass().getName()+")");
            }
        }
        return f;
    }
New to GrepCode? Check out our FAQ X