001package com.avaje.ebean.text.json; 002 003import java.util.LinkedHashMap; 004import java.util.Map; 005 006/** 007 * Provides the ability to customise the reading of JSON content. 008 * <p> 009 * You can register JsonReadBeanVisitors to customise the processing of the 010 * beans as they are processed and handle any custom JSON elements that 011 * could not be mapped to bean properties. 012 * </p> 013 */ 014public class JsonReadOptions { 015 016 protected final Map<String, JsonReadBeanVisitor<?>> visitorMap; 017 018 protected Object objectMapper; 019 020 /** 021 * Default constructor. 022 */ 023 public JsonReadOptions() { 024 this.visitorMap = new LinkedHashMap<String, JsonReadBeanVisitor<?>>(); 025 } 026 027 /** 028 * Return the map of JsonReadBeanVisitor's. 029 */ 030 public Map<String, JsonReadBeanVisitor<?>> getVisitorMap() { 031 return visitorMap; 032 } 033 034 /** 035 * Register a JsonReadBeanVisitor for the root level. 036 */ 037 public JsonReadOptions addRootVisitor(JsonReadBeanVisitor<?> visitor) { 038 return addVisitor(null, visitor); 039 } 040 041 /** 042 * Register a JsonReadBeanVisitor for a given path. 043 */ 044 public JsonReadOptions addVisitor(String path, JsonReadBeanVisitor<?> visitor) { 045 visitorMap.put(path, visitor); 046 return this; 047 } 048 049 /** 050 * Return the Jackson ObjectMapper to use (if not wanted to use the objectMapper set on the ServerConfig). 051 */ 052 public Object getObjectMapper() { 053 return objectMapper; 054 } 055 056 /** 057 * Set the Jackson ObjectMapper to use (if not wanted to use the objectMapper set on the ServerConfig). 058 */ 059 public void setObjectMapper(Object objectMapper) { 060 this.objectMapper = objectMapper; 061 } 062}