001package io.avaje.json.view; 002 003import io.avaje.json.JsonAdapter; 004 005import java.lang.invoke.MethodHandle; 006 007/** 008 * Builds a JsonView. 009 */ 010public interface ViewBuilder { 011 012 /** 013 * Begin a json object. 014 */ 015 void beginObject(String name, MethodHandle methodHandle); 016 017 /** 018 * Add a json property entry. 019 * @param name The name of the json property. 020 * @param adapter The adapter used for the property. 021 * @param methodHandle The MethodHandle of the "getter/accessor" for the property. 022 */ 023 void add(String name, JsonAdapter<?> adapter, MethodHandle methodHandle); 024 025 /** 026 * Add a nested json array. 027 */ 028 void addArray(String name, JsonAdapter<?> adapter, MethodHandle methodHandle); 029 030 /** 031 * End a json object. 032 */ 033 void endObject(); 034 035 /** 036 * Return a MethodHandle for public field access for the given class and field name. 037 */ 038 MethodHandle field(Class<?> cls, String name); 039 040 /** 041 * Return a MethodHandle for the "getter/accessor" for the given class and field name. 042 */ 043 MethodHandle method(Class<?> cls, String methodName, Class<?> returnType); 044 045}