001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.commons.bean; 018 019/** 020 * Bean-modeling SPI seam that exposes the dictionary-lookup surface the bean-runtime types need without 021 * coupling the bean-modeling layer to the marshalling-side {@code BeanRegistry}. 022 * 023 * <p> 024 * Marshalling-side {@code BeanRegistry} implements this interface. The bean-modeling-side 025 * only sees {@link BeanRegistryLookup} when it needs to translate between a raw {@link Class} 026 * and a polymorphic type name. All operations involving {@code ClassMeta} (e.g. 027 * {@code getClassMeta(String)}) remain on the marshalling-side {@code BeanRegistry} itself 028 * and are reached only via narrowing casts from marshalling-side call sites. 029 * 030 * <p> 031 * The bean-modeling layer never instantiates a registry directly — instances are always supplied 032 * by the marshalling layer via marshalling-side hooks. 033 * 034 * <h5 class='topic'>Thread safety</h5> 035 * Thread safety depends on implementation. 036 */ 037public interface BeanRegistryLookup { 038 039 /** 040 * Given the specified raw class, return the dictionary name for it, or <jk>null</jk> if not found. 041 * 042 * @param c The class to lookup in this registry. 043 * @return The dictionary name for the specified class, or <jk>null</jk> if not found. 044 */ 045 String getTypeName(Class<?> c); 046 047 /** 048 * Returns <jk>true</jk> if this dictionary has an entry for the specified type name. 049 * 050 * @param typeName The bean type name. 051 * @return <jk>true</jk> if this dictionary has an entry for the specified type name. 052 */ 053 boolean hasName(String typeName); 054}