Jackson Data Binding Source Code

Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".

  • Jackson Data Binding module allows you to converts JSON to and from POJO (Plain Old Java Object) using property accessor or using annotations.
  • Jackson Databind Source Code files are provided in the source packge (jackson-databind-2.12.4-sources.jar). You can download it at Jackson Maven Website.

    You can also browse Jackson Databind Source Code below:

    ✍: FYIcenter.com

    com/fasterxml/jackson/databind/util/ViewMatcher.java

    package com.fasterxml.jackson.databind.util;
    
    /**
     * Helper class used for checking whether a property is visible
     * in the active view
     */
    public class ViewMatcher implements java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
    
        protected final static ViewMatcher EMPTY = new ViewMatcher();
        
        public boolean isVisibleForView(Class<?> activeView) { return false; }
    
        public static ViewMatcher construct(Class<?>[] views)
        {
            if (views == null) {
                return EMPTY;
            }
            switch (views.length) {
            case 0:
                return EMPTY;
            case 1:
                return new Single(views[0]);
            }
            return new Multi(views);
        } 
        
        /*
        /**********************************************************
        /* Concrete sub-classes
        /**********************************************************
         */
    
        private final static class Single extends ViewMatcher
        {
            private static final long serialVersionUID = 1L;
    
            private final Class<?> _view;
            public Single(Class<?> v) { _view = v; }
            @Override
            public boolean isVisibleForView(Class<?> activeView) {
                return (activeView == _view) || _view.isAssignableFrom(activeView);
            }
        }
    
        private final static class Multi extends ViewMatcher
            implements java.io.Serializable
        {
            private static final long serialVersionUID = 1L;
    
            private final Class<?>[] _views;
    
            public Multi(Class<?>[] v) { _views = v; }
    
            @Override
            public boolean isVisibleForView(Class<?> activeView)
            {
                for (int i = 0, len = _views.length; i < len; ++i) {
                    Class<?> view = _views[i];
                    if ((activeView == view) || view.isAssignableFrom(activeView)) {
                        return true;
                    }
                }
                return false;
            }
        }
    }
    

    com/fasterxml/jackson/databind/util/ViewMatcher.java

     

    ⇒ Jackson Annotations Source Code

    ⇐ Download and Install Jackson Binary Package

    ⇑ Downloading and Reviewing jackson-*.jar

    ⇑⇑ Jackson - Java JSON library

    2022-03-29, 31725👍, 0💬