Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 75501200CC1 for ; Sun, 25 Jun 2017 16:44:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 73ACC160BD8; Sun, 25 Jun 2017 14:44:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2BDD2160BF7 for ; Sun, 25 Jun 2017 16:44:15 +0200 (CEST) Received: (qmail 95831 invoked by uid 500); 25 Jun 2017 14:44:14 -0000 Mailing-List: contact commits-help@juneau.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@juneau.incubator.apache.org Delivered-To: mailing list commits@juneau.incubator.apache.org Received: (qmail 95815 invoked by uid 99); 25 Jun 2017 14:44:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Jun 2017 14:44:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id D2C601A00F8 for ; Sun, 25 Jun 2017 14:44:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.022 X-Spam-Level: X-Spam-Status: No, score=-5.022 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 9NGx331NusO7 for ; Sun, 25 Jun 2017 14:44:03 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 1AD1760E4B for ; Sun, 25 Jun 2017 14:43:49 +0000 (UTC) Received: (qmail 94871 invoked by uid 99); 25 Jun 2017 14:43:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Jun 2017 14:43:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EFD44E96CA; Sun, 25 Jun 2017 14:43:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamesbognar@apache.org To: commits@juneau.incubator.apache.org Date: Sun, 25 Jun 2017 14:44:03 -0000 Message-Id: <62c9343a36764a0d8ebe593d29e2cab7@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/51] [partial] incubator-juneau-website git commit: Update Javadocs. archived-at: Sun, 25 Jun 2017 14:44:17 -0000 http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/5f11cb85/content/site/apidocs/src-html/org/apache/juneau/ClassMeta.html ---------------------------------------------------------------------- diff --git a/content/site/apidocs/src-html/org/apache/juneau/ClassMeta.html b/content/site/apidocs/src-html/org/apache/juneau/ClassMeta.html index 660fcb7..a8e9e20 100644 --- a/content/site/apidocs/src-html/org/apache/juneau/ClassMeta.html +++ b/content/site/apidocs/src-html/org/apache/juneau/ClassMeta.html @@ -65,7 +65,7 @@ 057 058 /** Class categories. */ 059 enum ClassCategory { -060 MAP, COLLECTION, CLASS, NUMBER, DECIMAL, BOOLEAN, CHAR, DATE, ARRAY, ENUM, OTHER, CHARSEQ, STR, OBJ, URI, BEANMAP, READER, INPUTSTREAM, VOID, ARGS +060 MAP, COLLECTION, CLASS, METHOD, NUMBER, DECIMAL, BOOLEAN, CHAR, DATE, ARRAY, ENUM, OTHER, CHARSEQ, STR, OBJ, URI, BEANMAP, READER, INPUTSTREAM, VOID, ARGS 061 } 062 063 final Class<T> innerClass; // The class being wrapped. @@ -119,1565 +119,1533 @@ 111 private final BeanRegistry beanRegistry; // The bean registry of this class meta (if it has one). 112 private final ClassMeta<?>[] args; // Arg types if this is an array of args. 113 -114 private static final Boolean BOOLEAN_DEFAULT = false; -115 private static final Character CHARACTER_DEFAULT = (char)0; -116 private static final Short SHORT_DEFAULT = (short)0; -117 private static final Integer INTEGER_DEFAULT = 0; -118 private static final Long LONG_DEFAULT = 0l; -119 private static final Float FLOAT_DEFAULT = 0f; -120 private static final Double DOUBLE_DEFAULT = 0d; -121 private static final Byte BYTE_DEFAULT = (byte)0; -122 -123 private ReadWriteLock lock = new ReentrantReadWriteLock(false); -124 private Lock rLock = lock.readLock(), wLock = lock.writeLock(); -125 -126 /** -127 * Construct a new {@code ClassMeta} based on the specified {@link Class}. -128 * -129 * @param innerClass The class being wrapped. -130 * @param beanContext The bean context that created this object. -131 * @param implClass For interfaces and abstract classes, this represents the "real" class to instantiate. -132 * Can be <jk>null</jk>. -133 * @param beanFilter The {@link BeanFilter} programmatically associated with this class. -134 * Can be <jk>null</jk>. -135 * @param pojoSwap The {@link PojoSwap} programmatically associated with this class. -136 * Can be <jk>null</jk>. -137 * @param childPojoSwap The child {@link PojoSwap PojoSwaps} programmatically associated with this class. -138 * These are the <code>PojoSwaps</code> that have normal classes that are subclasses of this class. -139 * Can be <jk>null</jk>. -140 * @param delayedInit Don't call init() in constructor. -141 * Used for delayed initialization when the possibility of class reference loops exist. -142 */ -143 @SuppressWarnings({ "rawtypes", "unchecked" }) -144 ClassMeta(Class<T> innerClass, BeanContext beanContext, Class<? extends T> implClass, BeanFilter beanFilter, PojoSwap<T,?> pojoSwap, PojoSwap<?,?>[] childPojoSwaps) { -145 this.innerClass = innerClass; -146 this.beanContext = beanContext; -147 -148 wLock.lock(); -149 try { -150 // We always immediately add this class meta to the bean context cache so that we can resolve recursive references. -151 if (beanContext != null && beanContext.cmCache != null) -152 beanContext.cmCache.put(innerClass, this); -153 -154 ClassMetaBuilder<T> builder = new ClassMetaBuilder(innerClass, beanContext, implClass, beanFilter, pojoSwap, childPojoSwaps); -155 -156 this.cc = builder.cc; -157 this.isDelegate = builder.isDelegate; -158 this.fromStringMethod = builder.fromStringMethod; -159 this.swapMethod = builder.swapMethod; -160 this.unswapMethod = builder.unswapMethod; -161 this.swapMethodType = builder.swapMethodType; -162 this.parentPropertyMethod = builder.parentPropertyMethod; -163 this.namePropertyMethod = builder.namePropertyMethod; -164 this.noArgConstructor = builder.noArgConstructor; -165 this.stringConstructor = builder.stringConstructor; -166 this.swapConstructor = builder.swapConstructor; -167 this.numberConstructor = builder.numberConstructor; -168 this.numberConstructorType = builder.numberConstructorType; -169 this.primitiveDefault = builder.primitiveDefault; -170 this.publicMethods = builder.publicMethods; -171 this.remoteableMethods = builder.remoteableMethods; -172 this.beanFilter = beanFilter; -173 this.pojoSwap = builder.pojoSwap; -174 this.extMeta = new MetadataMap(); -175 this.keyType = builder.keyType; -176 this.valueType = builder.valueType; -177 this.elementType = builder.elementType; -178 this.notABeanReason = builder.notABeanReason; -179 this.beanMeta = builder.beanMeta; -180 this.initException = builder.initException; -181 this.typePropertyName = builder.typePropertyName; -182 this.dictionaryName = builder.dictionaryName; -183 this.serializedClassMeta = builder.serializedClassMeta; -184 this.invocationHandler = builder.invocationHandler; -185 this.beanRegistry = builder.beanRegistry; -186 this.isMemberClass = builder.isMemberClass; -187 this.isAbstract = builder.isAbstract; -188 this.implClass = builder.implClass; -189 this.childUnswapMap = builder.childUnswapMap; -190 this.childSwapMap = builder.childSwapMap; -191 this.childPojoSwaps = builder.childPojoSwaps; -192 this.args = null; -193 } finally { -194 wLock.unlock(); -195 } -196 } -197 -198 /** -199 * Causes thread to wait until constructor has exited. +114 private ReadWriteLock lock = new ReentrantReadWriteLock(false); +115 private Lock rLock = lock.readLock(), wLock = lock.writeLock(); +116 +117 /** +118 * Construct a new {@code ClassMeta} based on the specified {@link Class}. +119 * +120 * @param innerClass The class being wrapped. +121 * @param beanContext The bean context that created this object. +122 * @param implClass For interfaces and abstract classes, this represents the "real" class to instantiate. +123 * Can be <jk>null</jk>. +124 * @param beanFilter The {@link BeanFilter} programmatically associated with this class. +125 * Can be <jk>null</jk>. +126 * @param pojoSwap The {@link PojoSwap} programmatically associated with this class. +127 * Can be <jk>null</jk>. +128 * @param childPojoSwap The child {@link PojoSwap PojoSwaps} programmatically associated with this class. +129 * These are the <code>PojoSwaps</code> that have normal classes that are subclasses of this class. +130 * Can be <jk>null</jk>. +131 * @param delayedInit Don't call init() in constructor. +132 * Used for delayed initialization when the possibility of class reference loops exist. +133 */ +134 @SuppressWarnings({ "rawtypes", "unchecked" }) +135 ClassMeta(Class<T> innerClass, BeanContext beanContext, Class<? extends T> implClass, BeanFilter beanFilter, PojoSwap<T,?> pojoSwap, PojoSwap<?,?>[] childPojoSwaps) { +136 this.innerClass = innerClass; +137 this.beanContext = beanContext; +138 +139 wLock.lock(); +140 try { +141 // We always immediately add this class meta to the bean context cache so that we can resolve recursive references. +142 if (beanContext != null && beanContext.cmCache != null) +143 beanContext.cmCache.put(innerClass, this); +144 +145 ClassMetaBuilder<T> builder = new ClassMetaBuilder(innerClass, beanContext, implClass, beanFilter, pojoSwap, childPojoSwaps); +146 +147 this.cc = builder.cc; +148 this.isDelegate = builder.isDelegate; +149 this.fromStringMethod = builder.fromStringMethod; +150 this.swapMethod = builder.swapMethod; +151 this.unswapMethod = builder.unswapMethod; +152 this.swapMethodType = builder.swapMethodType; +153 this.parentPropertyMethod = builder.parentPropertyMethod; +154 this.namePropertyMethod = builder.namePropertyMethod; +155 this.noArgConstructor = builder.noArgConstructor; +156 this.stringConstructor = builder.stringConstructor; +157 this.swapConstructor = builder.swapConstructor; +158 this.numberConstructor = builder.numberConstructor; +159 this.numberConstructorType = builder.numberConstructorType; +160 this.primitiveDefault = builder.primitiveDefault; +161 this.publicMethods = builder.publicMethods; +162 this.remoteableMethods = builder.remoteableMethods; +163 this.beanFilter = beanFilter; +164 this.pojoSwap = builder.pojoSwap; +165 this.extMeta = new MetadataMap(); +166 this.keyType = builder.keyType; +167 this.valueType = builder.valueType; +168 this.elementType = builder.elementType; +169 this.notABeanReason = builder.notABeanReason; +170 this.beanMeta = builder.beanMeta; +171 this.initException = builder.initException; +172 this.typePropertyName = builder.typePropertyName; +173 this.dictionaryName = builder.dictionaryName; +174 this.serializedClassMeta = builder.serializedClassMeta; +175 this.invocationHandler = builder.invocationHandler; +176 this.beanRegistry = builder.beanRegistry; +177 this.isMemberClass = builder.isMemberClass; +178 this.isAbstract = builder.isAbstract; +179 this.implClass = builder.implClass; +180 this.childUnswapMap = builder.childUnswapMap; +181 this.childSwapMap = builder.childSwapMap; +182 this.childPojoSwaps = builder.childPojoSwaps; +183 this.args = null; +184 } finally { +185 wLock.unlock(); +186 } +187 } +188 +189 /** +190 * Causes thread to wait until constructor has exited. +191 */ +192 final void waitForInit() { +193 rLock.lock(); +194 rLock.unlock(); +195 } +196 +197 /** +198 * Copy constructor. +199 * Used for creating Map and Collection class metas that shouldn't be cached. 200 */ -201 final void waitForInit() { -202 rLock.lock(); -203 rLock.unlock(); -204 } -205 -206 /** -207 * Copy constructor. -208 * Used for creating Map and Collection class metas that shouldn't be cached. -209 */ -210 ClassMeta(ClassMeta<T> mainType, ClassMeta<?> keyType, ClassMeta<?> valueType, ClassMeta<?> elementType) { -211 this.innerClass = mainType.innerClass; -212 this.implClass = mainType.implClass; -213 this.childPojoSwaps = mainType.childPojoSwaps; -214 this.childSwapMap = mainType.childSwapMap; -215 this.childUnswapMap = mainType.childUnswapMap; -216 this.cc = mainType.cc; -217 this.fromStringMethod = mainType.fromStringMethod; -218 this.noArgConstructor = mainType.noArgConstructor; -219 this.stringConstructor = mainType.stringConstructor; -220 this.numberConstructor = mainType.numberConstructor; -221 this.swapConstructor = mainType.swapConstructor; -222 this.swapMethodType = mainType.swapMethodType; -223 this.numberConstructorType = mainType.numberConstructorType; -224 this.swapMethod = mainType.swapMethod; -225 this.unswapMethod = mainType.unswapMethod; -226 this.namePropertyMethod = mainType.namePropertyMethod; -227 this.parentPropertyMethod = mainType.parentPropertyMethod; -228 this.isDelegate = mainType.isDelegate; -229 this.isAbstract = mainType.isAbstract; -230 this.isMemberClass = mainType.isMemberClass; -231 this.primitiveDefault = mainType.primitiveDefault; -232 this.remoteableMethods = mainType.remoteableMethods; -233 this.publicMethods = mainType.publicMethods; -234 this.beanContext = mainType.beanContext; -235 this.serializedClassMeta = this; -236 this.elementType = elementType; -237 this.keyType = keyType; -238 this.valueType = valueType; -239 this.invocationHandler = mainType.invocationHandler; -240 this.beanMeta = mainType.beanMeta; -241 this.typePropertyName = mainType.typePropertyName; -242 this.dictionaryName = mainType.dictionaryName; -243 this.notABeanReason = mainType.notABeanReason; -244 this.pojoSwap = mainType.pojoSwap; -245 this.beanFilter = mainType.beanFilter; -246 this.extMeta = mainType.extMeta; -247 this.initException = mainType.initException; -248 this.beanRegistry = mainType.beanRegistry; -249 this.args = null; -250 } -251 -252 /** -253 * Constructor for args-arrays. -254 */ -255 @SuppressWarnings("unchecked") -256 ClassMeta(ClassMeta<?>[] args) { -257 this.innerClass = (Class<T>) Object[].class; -258 this.args = args; -259 this.implClass = null; -260 this.childPojoSwaps = null; -261 this.childSwapMap = null; -262 this.childUnswapMap = null; -263 this.cc = ARGS; -264 this.fromStringMethod = null; -265 this.noArgConstructor = null; -266 this.stringConstructor = null; -267 this.numberConstructor = null; -268 this.swapConstructor = null; -269 this.swapMethodType = null; -270 this.numberConstructorType = null; -271 this.swapMethod = null; -272 this.unswapMethod = null; -273 this.namePropertyMethod = null; -274 this.parentPropertyMethod = null; -275 this.isDelegate = false; -276 this.isAbstract = false; -277 this.isMemberClass = false; -278 this.primitiveDefault = null; -279 this.remoteableMethods = null; -280 this.publicMethods = null; -281 this.beanContext = null; -282 this.serializedClassMeta = this; -283 this.elementType = null; -284 this.keyType = null; -285 this.valueType = null; -286 this.invocationHandler = null; -287 this.beanMeta = null; -288 this.typePropertyName = null; -289 this.dictionaryName = null; -290 this.notABeanReason = null; -291 this.pojoSwap = null; -292 this.beanFilter = null; -293 this.extMeta = new MetadataMap(); -294 this.initException = null; -295 this.beanRegistry = null; -296 } -297 -298 @SuppressWarnings({"unchecked","rawtypes","hiding"}) -299 private class ClassMetaBuilder<T> { -300 Class<T> innerClass; -301 Class<? extends T> implClass; -302 BeanContext beanContext; -303 ClassCategory cc = ClassCategory.OTHER; -304 boolean -305 isDelegate = false, -306 isMemberClass = false, -307 isAbstract = false; -308 Method -309 fromStringMethod = null, -310 swapMethod = null, -311 unswapMethod = null; -312 Setter -313 parentPropertyMethod = null, -314 namePropertyMethod = null; -315 Constructor<T> -316 noArgConstructor = null, -317 stringConstructor = null, -318 swapConstructor = null, -319 numberConstructor = null; -320 Class<?> -321 swapMethodType = null, -322 numberConstructorType = null; -323 Object primitiveDefault = null; -324 Map<String,Method> -325 publicMethods = new LinkedHashMap<String,Method>(), -326 remoteableMethods = new LinkedHashMap<String,Method>(); -327 ClassMeta<?> -328 keyType = null, -329 valueType = null, -330 elementType = null, -331 serializedClassMeta = null; -332 String -333 typePropertyName = null, -334 notABeanReason = null, -335 dictionaryName = null; -336 Throwable initException = null; -337 BeanMeta beanMeta = null; -338 PojoSwap pojoSwap = null; -339 InvocationHandler invocationHandler = null; -340 BeanRegistry beanRegistry = null; -341 PojoSwap<?,?>[] childPojoSwaps; -342 ConcurrentHashMap<Class<?>,PojoSwap<?,?>> -343 childSwapMap, -344 childUnswapMap; +201 ClassMeta(ClassMeta<T> mainType, ClassMeta<?> keyType, ClassMeta<?> valueType, ClassMeta<?> elementType) { +202 this.innerClass = mainType.innerClass; +203 this.implClass = mainType.implClass; +204 this.childPojoSwaps = mainType.childPojoSwaps; +205 this.childSwapMap = mainType.childSwapMap; +206 this.childUnswapMap = mainType.childUnswapMap; +207 this.cc = mainType.cc; +208 this.fromStringMethod = mainType.fromStringMethod; +209 this.noArgConstructor = mainType.noArgConstructor; +210 this.stringConstructor = mainType.stringConstructor; +211 this.numberConstructor = mainType.numberConstructor; +212 this.swapConstructor = mainType.swapConstructor; +213 this.swapMethodType = mainType.swapMethodType; +214 this.numberConstructorType = mainType.numberConstructorType; +215 this.swapMethod = mainType.swapMethod; +216 this.unswapMethod = mainType.unswapMethod; +217 this.namePropertyMethod = mainType.namePropertyMethod; +218 this.parentPropertyMethod = mainType.parentPropertyMethod; +219 this.isDelegate = mainType.isDelegate; +220 this.isAbstract = mainType.isAbstract; +221 this.isMemberClass = mainType.isMemberClass; +222 this.primitiveDefault = mainType.primitiveDefault; +223 this.remoteableMethods = mainType.remoteableMethods; +224 this.publicMethods = mainType.publicMethods; +225 this.beanContext = mainType.beanContext; +226 this.serializedClassMeta = this; +227 this.elementType = elementType; +228 this.keyType = keyType; +229 this.valueType = valueType; +230 this.invocationHandler = mainType.invocationHandler; +231 this.beanMeta = mainType.beanMeta; +232 this.typePropertyName = mainType.typePropertyName; +233 this.dictionaryName = mainType.dictionaryName; +234 this.notABeanReason = mainType.notABeanReason; +235 this.pojoSwap = mainType.pojoSwap; +236 this.beanFilter = mainType.beanFilter; +237 this.extMeta = mainType.extMeta; +238 this.initException = mainType.initException; +239 this.beanRegistry = mainType.beanRegistry; +240 this.args = null; +241 } +242 +243 /** +244 * Constructor for args-arrays. +245 */ +246 @SuppressWarnings("unchecked") +247 ClassMeta(ClassMeta<?>[] args) { +248 this.innerClass = (Class<T>) Object[].class; +249 this.args = args; +250 this.implClass = null; +251 this.childPojoSwaps = null; +252 this.childSwapMap = null; +253 this.childUnswapMap = null; +254 this.cc = ARGS; +255 this.fromStringMethod = null; +256 this.noArgConstructor = null; +257 this.stringConstructor = null; +258 this.numberConstructor = null; +259 this.swapConstructor = null; +260 this.swapMethodType = null; +261 this.numberConstructorType = null; +262 this.swapMethod = null; +263 this.unswapMethod = null; +264 this.namePropertyMethod = null; +265 this.parentPropertyMethod = null; +266 this.isDelegate = false; +267 this.isAbstract = false; +268 this.isMemberClass = false; +269 this.primitiveDefault = null; +270 this.remoteableMethods = null; +271 this.publicMethods = null; +272 this.beanContext = null; +273 this.serializedClassMeta = this; +274 this.elementType = null; +275 this.keyType = null; +276 this.valueType = null; +277 this.invocationHandler = null; +278 this.beanMeta = null; +279 this.typePropertyName = null; +280 this.dictionaryName = null; +281 this.notABeanReason = null; +282 this.pojoSwap = null; +283 this.beanFilter = null; +284 this.extMeta = new MetadataMap(); +285 this.initException = null; +286 this.beanRegistry = null; +287 } +288 +289 @SuppressWarnings({"unchecked","rawtypes","hiding"}) +290 private class ClassMetaBuilder<T> { +291 Class<T> innerClass; +292 Class<? extends T> implClass; +293 BeanContext beanContext; +294 ClassCategory cc = ClassCategory.OTHER; +295 boolean +296 isDelegate = false, +297 isMemberClass = false, +298 isAbstract = false; +299 Method +300 fromStringMethod = null, +301 swapMethod = null, +302 unswapMethod = null; +303 Setter +304 parentPropertyMethod = null, +305 namePropertyMethod = null; +306 Constructor<T> +307 noArgConstructor = null, +308 stringConstructor = null, +309 swapConstructor = null, +310 numberConstructor = null; +311 Class<?> +312 swapMethodType = null, +313 numberConstructorType = null; +314 Object primitiveDefault = null; +315 Map<String,Method> +316 publicMethods = new LinkedHashMap<String,Method>(), +317 remoteableMethods = new LinkedHashMap<String,Method>(); +318 ClassMeta<?> +319 keyType = null, +320 valueType = null, +321 elementType = null, +322 serializedClassMeta = null; +323 String +324 typePropertyName = null, +325 notABeanReason = null, +326 dictionaryName = null; +327 Throwable initException = null; +328 BeanMeta beanMeta = null; +329 PojoSwap pojoSwap = null; +330 InvocationHandler invocationHandler = null; +331 BeanRegistry beanRegistry = null; +332 PojoSwap<?,?>[] childPojoSwaps; +333 ConcurrentHashMap<Class<?>,PojoSwap<?,?>> +334 childSwapMap, +335 childUnswapMap; +336 +337 private ClassMetaBuilder(Class<T> innerClass, BeanContext beanContext, Class<? extends T> implClass, BeanFilter beanFilter, PojoSwap<T,?> pojoSwap, PojoSwap<?,?>[] childPojoSwaps) { +338 this.innerClass = innerClass; +339 this.beanContext = beanContext; +340 +341 this.implClass = implClass; +342 this.childPojoSwaps = childPojoSwaps; +343 this.childSwapMap = childPojoSwaps == null ? null : new ConcurrentHashMap<Class<?>,PojoSwap<?,?>>(); +344 this.childUnswapMap = childPojoSwaps == null ? null : new ConcurrentHashMap<Class<?>,PojoSwap<?,?>>(); 345 -346 private ClassMetaBuilder(Class<T> innerClass, BeanContext beanContext, Class<? extends T> implClass, BeanFilter beanFilter, PojoSwap<T,?> pojoSwap, PojoSwap<?,?>[] childPojoSwaps) { -347 this.innerClass = innerClass; -348 this.beanContext = beanContext; -349 -350 this.implClass = implClass; -351 this.childPojoSwaps = childPojoSwaps; -352 this.childSwapMap = childPojoSwaps == null ? null : new ConcurrentHashMap<Class<?>,PojoSwap<?,?>>(); -353 this.childUnswapMap = childPojoSwaps == null ? null : new ConcurrentHashMap<Class<?>,PojoSwap<?,?>>(); -354 -355 Class<T> c = innerClass; -356 if (c.isPrimitive()) { -357 if (c == Boolean.TYPE) -358 cc = BOOLEAN; -359 else if (c == Byte.TYPE || c == Short.TYPE || c == Integer.TYPE || c == Long.TYPE || c == Float.TYPE || c == Double.TYPE) { -360 if (c == Float.TYPE || c == Double.TYPE) -361 cc = DECIMAL; -362 else -363 cc = NUMBER; -364 } -365 else if (c == Character.TYPE) -366 cc = CHAR; -367 else if (c == void.class || c == Void.class) -368 cc = VOID; -369 } else { -370 if (isParentClass(Delegate.class, c)) -371 isDelegate = true; -372 -373 if (c == Object.class) -374 cc = OBJ; -375 else if (c.isEnum()) -376 cc = ENUM; -377 else if (c.equals(Class.class)) -378 cc = CLASS; -379 else if (isParentClass(CharSequence.class, c)) { -380 if (c.equals(String.class)) -381 cc = STR; -382 else -383 cc = CHARSEQ; -384 } -385 else if (isParentClass(Number.class, c)) { -386 if (isParentClass(Float.class, c) || isParentClass(Double.class, c)) -387 cc = DECIMAL; -388 else -389 cc = NUMBER; -390 } -391 else if (isParentClass(Collection.class, c)) -392 cc = COLLECTION; -393 else if (isParentClass(Map.class, c)) { -394 if (isParentClass(BeanMap.class, c)) -395 cc = BEANMAP; -396 else -397 cc = MAP; -398 } -399 else if (c == Character.class) -400 cc = CHAR; -401 else if (c == Boolean.class) -402 cc = BOOLEAN; -403 else if (isParentClass(Date.class, c) || isParentClass(Calendar.class, c)) -404 cc = DATE; -405 else if (c.isArray()) -406 cc = ARRAY; -407 else if (isParentClass(URL.class, c) || isParentClass(URI.class, c) || c.isAnnotationPresent(org.apache.juneau.annotation.URI.class)) -408 cc = URI; -409 else if (isParentClass(Reader.class, c)) -410 cc = READER; -411 else if (isParentClass(InputStream.class, c)) -412 cc = INPUTSTREAM; -413 } -414 -415 isMemberClass = c.isMemberClass() && ! isStatic(c); -416 -417 // Find static fromString(String) or equivalent method. -418 // fromString() must be checked before valueOf() so that Enum classes can create their own -419 // specialized fromString() methods to override the behavior of Enum.valueOf(String). -420 // valueOf() is used by enums. -421 // parse() is used by the java logging Level class. -422 // forName() is used by Class and Charset -423 for (String methodName : new String[]{"fromString","fromValue","valueOf","parse","parseString","forName","forString"}) { -424 if (fromStringMethod == null) { -425 for (Method m : c.getMethods()) { -426 if (isStatic(m) && isPublic(m) && isNotDeprecated(m)) { -427 String mName = m.getName(); -428 if (mName.equals(methodName) && m.getReturnType() == c) { -429 Class<?>[] args = m.getParameterTypes(); -430 if (args.length == 1 && args[0] == String.class) { -431 fromStringMethod = m; -432 break; -433 } -434 } -435 } -436 } -437 } -438 } -439 -440 // Special cases -441 try { -442 if (c == TimeZone.class) -443 fromStringMethod = c.getMethod("getTimeZone", String.class); -444 else if (c == Locale.class) -445 fromStringMethod = LocaleAsString.class.getMethod("fromString", String.class); -446 } catch (NoSuchMethodException e1) {} -447 -448 // Find swap() method if present. -449 for (Method m : c.getMethods()) { -450 if (isPublic(m) && isNotDeprecated(m) && ! isStatic(m)) { -451 String mName = m.getName(); -452 if (mName.equals("swap")) { -453 Class<?>[] pt = m.getParameterTypes(); -454 if (pt.length == 1 && pt[0] == BeanSession.class) { -455 swapMethod = m; -456 swapMethodType = m.getReturnType(); -457 break; -458 } -459 } -460 } -461 } -462 // Find unswap() method if present. -463 if (swapMethod != null) { -464 for (Method m : c.getMethods()) { -465 if (isPublic(m) && isNotDeprecated(m) && isStatic(m)) { -466 String mName = m.getName(); -467 if (mName.equals("unswap")) { -468 Class<?>[] pt = m.getParameterTypes(); -469 if (pt.length == 2 && pt[0] == BeanSession.class && pt[1] == swapMethodType) { -470 unswapMethod = m; -471 break; -472 } -473 } -474 } +346 Class<T> c = innerClass; +347 if (c.isPrimitive()) { +348 if (c == Boolean.TYPE) +349 cc = BOOLEAN; +350 else if (c == Byte.TYPE || c == Short.TYPE || c == Integer.TYPE || c == Long.TYPE || c == Float.TYPE || c == Double.TYPE) { +351 if (c == Float.TYPE || c == Double.TYPE) +352 cc = DECIMAL; +353 else +354 cc = NUMBER; +355 } +356 else if (c == Character.TYPE) +357 cc = CHAR; +358 else if (c == void.class || c == Void.class) +359 cc = VOID; +360 } else { +361 if (isParentClass(Delegate.class, c)) +362 isDelegate = true; +363 +364 if (c == Object.class) +365 cc = OBJ; +366 else if (c.isEnum()) +367 cc = ENUM; +368 else if (c.equals(Class.class)) +369 cc = CLASS; +370 else if (isParentClass(Method.class, c)) +371 cc = METHOD; +372 else if (isParentClass(CharSequence.class, c)) { +373 if (c.equals(String.class)) +374 cc = STR; +375 else +376 cc = CHARSEQ; +377 } +378 else if (isParentClass(Number.class, c)) { +379 if (isParentClass(Float.class, c) || isParentClass(Double.class, c)) +380 cc = DECIMAL; +381 else +382 cc = NUMBER; +383 } +384 else if (isParentClass(Collection.class, c)) +385 cc = COLLECTION; +386 else if (isParentClass(Map.class, c)) { +387 if (isParentClass(BeanMap.class, c)) +388 cc = BEANMAP; +389 else +390 cc = MAP; +391 } +392 else if (c == Character.class) +393 cc = CHAR; +394 else if (c == Boolean.class) +395 cc = BOOLEAN; +396 else if (isParentClass(Date.class, c) || isParentClass(Calendar.class, c)) +397 cc = DATE; +398 else if (c.isArray()) +399 cc = ARRAY; +400 else if (isParentClass(URL.class, c) || isParentClass(URI.class, c) || c.isAnnotationPresent(org.apache.juneau.annotation.URI.class)) +401 cc = URI; +402 else if (isParentClass(Reader.class, c)) +403 cc = READER; +404 else if (isParentClass(InputStream.class, c)) +405 cc = INPUTSTREAM; +406 } +407 +408 isMemberClass = c.isMemberClass() && ! isStatic(c); +409 +410 // Find static fromString(String) or equivalent method. +411 // fromString() must be checked before valueOf() so that Enum classes can create their own +412 // specialized fromString() methods to override the behavior of Enum.valueOf(String). +413 // valueOf() is used by enums. +414 // parse() is used by the java logging Level class. +415 // forName() is used by Class and Charset +416 for (String methodName : new String[]{"fromString","fromValue","valueOf","parse","parseString","forName","forString"}) { +417 if (fromStringMethod == null) { +418 for (Method m : c.getMethods()) { +419 if (isStatic(m) && isPublic(m) && isNotDeprecated(m)) { +420 String mName = m.getName(); +421 if (mName.equals(methodName) && m.getReturnType() == c) { +422 Class<?>[] args = m.getParameterTypes(); +423 if (args.length == 1 && args[0] == String.class) { +424 fromStringMethod = m; +425 break; +426 } +427 } +428 } +429 } +430 } +431 } +432 +433 // Special cases +434 try { +435 if (c == TimeZone.class) +436 fromStringMethod = c.getMethod("getTimeZone", String.class); +437 else if (c == Locale.class) +438 fromStringMethod = LocaleAsString.class.getMethod("fromString", String.class); +439 } catch (NoSuchMethodException e1) {} +440 +441 // Find swap() method if present. +442 for (Method m : c.getMethods()) { +443 if (isPublic(m) && isNotDeprecated(m) && ! isStatic(m)) { +444 String mName = m.getName(); +445 if (mName.equals("swap")) { +446 Class<?>[] pt = m.getParameterTypes(); +447 if (pt.length == 1 && pt[0] == BeanSession.class) { +448 swapMethod = m; +449 swapMethodType = m.getReturnType(); +450 break; +451 } +452 } +453 } +454 } +455 // Find unswap() method if present. +456 if (swapMethod != null) { +457 for (Method m : c.getMethods()) { +458 if (isPublic(m) && isNotDeprecated(m) && isStatic(m)) { +459 String mName = m.getName(); +460 if (mName.equals("unswap")) { +461 Class<?>[] pt = m.getParameterTypes(); +462 if (pt.length == 2 && pt[0] == BeanSession.class && pt[1] == swapMethodType) { +463 unswapMethod = m; +464 break; +465 } +466 } +467 } +468 } +469 } +470 +471 for (Field f : getAllFields(c, true)) { +472 if (f.isAnnotationPresent(ParentProperty.class)) { +473 f.setAccessible(true); +474 parentPropertyMethod = new Setter.FieldSetter(f); 475 } -476 } -477 -478 for (Field f : getAllFields(c, true)) { -479 if (f.isAnnotationPresent(ParentProperty.class)) { -480 f.setAccessible(true); -481 parentPropertyMethod = new Setter.FieldSetter(f); -482 } -483 if (f.isAnnotationPresent(NameProperty.class)) { -484 f.setAccessible(true); -485 namePropertyMethod = new Setter.FieldSetter(f); -486 } -487 } -488 -489 // Find @NameProperty and @ParentProperty methods if present. -490 for (Method m : getAllMethods(c, true)) { -491 if (m.isAnnotationPresent(ParentProperty.class) && m.getParameterTypes().length == 1) { -492 m.setAccessible(true); -493 parentPropertyMethod = new Setter.MethodSetter(m); -494 } -495 if (m.isAnnotationPresent(NameProperty.class) && m.getParameterTypes().length == 1) { -496 m.setAccessible(true); -497 namePropertyMethod = new Setter.MethodSetter(m); -498 } -499 } -500 -501 // Note: Primitive types are normally abstract. -502 isAbstract = Modifier.isAbstract(c.getModifiers()) && ! c.isPrimitive(); -503 -504 // Find constructor(String) method if present. -505 for (Constructor cs : c.getConstructors()) { -506 if (isPublic(cs) && isNotDeprecated(cs)) { -507 Class<?>[] args = cs.getParameterTypes(); -508 if (args.length == (isMemberClass ? 1 : 0) && c != Object.class && ! isAbstract) { -509 noArgConstructor = cs; -510 } else if (args.length == (isMemberClass ? 2 : 1)) { -511 Class<?> arg = args[(isMemberClass ? 1 : 0)]; -512 if (arg == String.class) -513 stringConstructor = cs; -514 else if (swapMethodType != null && swapMethodType.isAssignableFrom(arg)) -515 swapConstructor = cs; -516 else if (cc != NUMBER && (Number.class.isAssignableFrom(arg) || (arg.isPrimitive() && (arg == int.class || arg == short.class || arg == long.class || arg == float.class || arg == double.class)))) { -517 numberConstructor = cs; -518 numberConstructorType = getWrapperIfPrimitive(arg); -519 } -520 } -521 } -522 } -523 -524 if (c.isPrimitive()) { -525 if (c == Boolean.TYPE) -526 primitiveDefault = BOOLEAN_DEFAULT; -527 else if (c == Character.TYPE) -528 primitiveDefault = CHARACTER_DEFAULT; -529 else if (c == Short.TYPE) -530 primitiveDefault = SHORT_DEFAULT; -531 else if (c == Integer.TYPE) -532 primitiveDefault = INTEGER_DEFAULT; -533 else if (c == Long.TYPE) -534 primitiveDefault = LONG_DEFAULT; -535 else if (c == Float.TYPE) -536 primitiveDefault = FLOAT_DEFAULT; -537 else if (c == Double.TYPE) -538 primitiveDefault = DOUBLE_DEFAULT; -539 else if (c == Byte.TYPE) -540 primitiveDefault = BYTE_DEFAULT; -541 } else { -542 if (c == Boolean.class) -543 primitiveDefault = BOOLEAN_DEFAULT; -544 else if (c == Character.class) -545 primitiveDefault = CHARACTER_DEFAULT; -546 else if (c == Short.class) -547 primitiveDefault = SHORT_DEFAULT; -548 else if (c == Integer.class) -549 primitiveDefault = INTEGER_DEFAULT; -550 else if (c == Long.class) -551 primitiveDefault = LONG_DEFAULT; -552 else if (c == Float.class) -553 primitiveDefault = FLOAT_DEFAULT; -554 else if (c == Double.class) -555 primitiveDefault = DOUBLE_DEFAULT; -556 else if (c == Byte.class) -557 primitiveDefault = BYTE_DEFAULT; -558 } -559 -560 for (Method m : c.getMethods()) -561 if (isPublic(m) && isNotDeprecated(m)) -562 publicMethods.put(getMethodSignature(m), m); -563 -564 Map<Class<?>,Remoteable> remoteableMap = findAnnotationsMap(Remoteable.class, c); -565 if (! remoteableMap.isEmpty()) { -566 Map.Entry<Class<?>,Remoteable> e = remoteableMap.entrySet().iterator().next(); // Grab the first one. -567 Class<?> ic = e.getKey(); -568 Remoteable r = e.getValue(); -569 String methodPaths = r.methodPaths(); -570 String expose = r.expose(); -571 for (Method m : "DECLARED".equals(expose) ? ic.getDeclaredMethods() : ic.getMethods()) { -572 if (isPublic(m)) { -573 RemoteMethod rm = m.getAnnotation(RemoteMethod.class); -574 if (rm != null || ! "ANNOTATED".equals(expose)) { -575 String path = "NAME".equals(methodPaths) ? m.getName() : getMethodSignature(m); -576 remoteableMethods.put(path, m); -577 } -578 } -579 } -580 } +476 if (f.isAnnotationPresent(NameProperty.class)) { +477 f.setAccessible(true); +478 namePropertyMethod = new Setter.FieldSetter(f); +479 } +480 } +481 +482 // Find @NameProperty and @ParentProperty methods if present. +483 for (Method m : getAllMethods(c, true)) { +484 if (m.isAnnotationPresent(ParentProperty.class) && m.getParameterTypes().length == 1) { +485 m.setAccessible(true); +486 parentPropertyMethod = new Setter.MethodSetter(m); +487 } +488 if (m.isAnnotationPresent(NameProperty.class) && m.getParameterTypes().length == 1) { +489