Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.util;

Helper class used for checking whether a property is visible in the active view
 
 public abstract class ViewMatcher
 {
     public abstract boolean isVisibleForView(Class<?> activeView);
    public static ViewMatcher construct(Class<?>[] views)
    {
        if (views == null) {
            return .;
        }
        switch (views.length) {
        case 0:
            return .;
        case 1:
            return new Single(views[0]);
        }
        return new Multi(views);
    } 
    
    /*
    /**********************************************************
    /* Concrete sub-classes
    /**********************************************************
     */
    private final static class Empty extends ViewMatcher
        implements java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        final static Empty instance = new Empty();
        @Override
        public boolean isVisibleForView(Class<?> activeView) {
            return false;
        }
    }
    private final static class Single extends ViewMatcher
        implements java.io.Serializable
    {
        private static final long serialVersionUID = 1L;
        private final Class<?> _view;
        public Single(Class<?> v) {  = v; }
        @Override
        public boolean isVisibleForView(Class<?> activeView) {
            return (activeView == ) || .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) {  = v; }
        @Override
        public boolean isVisibleForView(Class<?> activeView)
        {
            for (int i = 0, len = .i < len; ++i) {
                Class<?> view = [i];
                if ((activeView == view) || view.isAssignableFrom(activeView)) {
                    return true;
                }
            }
            return false;
        }
    }
New to GrepCode? Check out our FAQ X