001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.transform; 014 015import static org.apache.juneau.internal.StringUtils.*; 016 017import java.util.*; 018 019import org.apache.juneau.*; 020import org.apache.juneau.annotation.*; 021 022/** 023 * Bean filter builder initialized from the contents of a {@link Bean @Bean} annotation found on a class. 024 * 025 * <p> 026 * <b>*** Internal class - Not intended for external use ***</b> 027 * 028 * @param <T> Annotated bean class. 029 */ 030public final class AnnotationBeanFilterBuilder<T> extends BeanFilterBuilder<T> { 031 032 /** 033 * Constructor. 034 * 035 * @param annotatedClass The class found to have a {@link Bean @Bean} annotation. 036 * @param annotations 037 * The {@link Bean @Bean} annotations found on the class and all parent classes in child-to-parent order. 038 * @throws Exception Thrown from property namer constructor. 039 */ 040 @SuppressWarnings("deprecation") 041 public AnnotationBeanFilterBuilder(Class<T> annotatedClass, List<Bean> annotations) throws Exception { 042 super(annotatedClass); 043 044 ListIterator<Bean> li = annotations.listIterator(annotations.size()); 045 while (li.hasPrevious()) { 046 Bean b = li.previous(); 047 048 if (! b.properties().isEmpty()) 049 bpi(split(b.properties())); 050 051 if (! b.bpi().isEmpty()) 052 bpi(split(b.bpi())); 053 054 if (! b.typeName().isEmpty()) 055 typeName(b.typeName()); 056 057 if (b.sort()) 058 sortProperties(true); 059 060 if (b.fluentSetters()) 061 fluentSetters(true); 062 063 if (! b.excludeProperties().isEmpty()) 064 bpx(split(b.excludeProperties())); 065 066 if (! b.bpx().isEmpty()) 067 bpx(split(b.bpx())); 068 069 if (! b.bpro().isEmpty()) 070 bpro(split(b.bpro())); 071 072 if (! b.bpwo().isEmpty()) 073 bpwo(split(b.bpwo())); 074 075 if (b.propertyNamer() != PropertyNamerDefault.class) 076 propertyNamer(b.propertyNamer()); 077 078 if (b.interfaceClass() != Object.class) 079 interfaceClass(b.interfaceClass()); 080 081 if (b.stopClass() != Object.class) 082 stopClass(b.stopClass()); 083 084 if (b.beanDictionary().length > 0) 085 dictionary(b.beanDictionary()); 086 087 if (b.dictionary().length > 0) 088 dictionary(b.dictionary()); 089 090 if (b.propertyFilter() != PropertyFilter.class) 091 propertyFilter(b.propertyFilter()); 092 } 093 } 094}