pax_global_header00006660000000000000000000000064121124534320014507gustar00rootroot0000000000000052 comment=7a831e9a107144e8bade0d16cd4760d76ec4adef fest-reflect-fest-reflect-1.4.1/000077500000000000000000000000001211245343200164565ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/.gitignore000066400000000000000000000000531211245343200204440ustar00rootroot00000000000000.classpath .project /bin /target .settings fest-reflect-fest-reflect-1.4.1/LICENSE.txt000066400000000000000000000261361211245343200203110ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. fest-reflect-fest-reflect-1.4.1/pom.xml000066400000000000000000000041701211245343200177750ustar00rootroot00000000000000 4.0.0 org.easytesting fest-reflect 1.4.1 FEST Reflection Fluent Interface that simplifies usage of Java Reflection 2007 http://fest.easytesting.org/reflect org.easytesting fest 1.0.15 Easy Testing Group http://groups.google.com/group/easytesting http://groups.google.com/group/easytesting http://groups.google.com/group/easytesting scm:git:git@github.com:alexruiz/fest-reflect.git scm:git:git://github.com/alexruiz/fest-reflect.git https://github.com/alexruiz/fest-reflect JIRA http://jira.codehaus.org/browse/FEST org.easytesting fest-util 1.2.4 jar org.easytesting fest-test 1.2 jar test junit junit 4.7 jar test org.mockito mockito-all test 1.9.0 fest-reflect-fest-reflect-1.4.1/src/000077500000000000000000000000001211245343200172455ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/000077500000000000000000000000001211245343200201715ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/000077500000000000000000000000001211245343200211125ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/000077500000000000000000000000001211245343200217015ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/000077500000000000000000000000001211245343200226425ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/000077500000000000000000000000001211245343200242665ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/000077500000000000000000000000001211245343200270005ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/Invoker.java000066400000000000000000000132231211245343200312610ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.beanproperty; import static org.fest.util.Strings.concat; import static org.fest.util.Strings.quote; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.field.StaticFieldName; import org.fest.reflect.field.StaticFieldType; import org.fest.reflect.reference.TypeRef; /** * Understands the use of instrospection to access a property from a JavaBean. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the property "name"
 *   String name = {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#get() get}();
 *
 *   // Sets the value of the property "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 *
 *   // Retrieves the value of the static property "count"
 *   int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#get() get}();
 *
 *   // Sets the value of the static property "count" to 3
 *   {@link org.fest.reflect.core.Reflection#staticField(String) property}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#set(Object) set}(3);
 * 
*

* * @param the declared type for the property to access. * * @author Alex Ruiz * * @since 1.2 */ public final class Invoker { static Invoker newInvoker(String name, TypeRef expectedType, Object target) { return createInvoker(name, expectedType.rawType(), target); } static Invoker newInvoker(String name, Class expectedType, Object target) { return createInvoker(name, expectedType, target); } private static Invoker createInvoker(String name, Class expectedType, Object target) { PropertyDescriptor descriptor = descriptorForProperty(name, target); verifyCorrectType(name, target, expectedType, descriptor); return new Invoker(name, target, descriptor); } private static PropertyDescriptor descriptorForProperty(String propertyName, Object target) { BeanInfo beanInfo = null; Class type = target.getClass(); try { beanInfo = Introspector.getBeanInfo(type); } catch (Exception e) { throw new ReflectionError(concat("Unable to get BeanInfo for type ", type.getName()), e); } for (PropertyDescriptor d : beanInfo.getPropertyDescriptors()) if (propertyName.equals(d.getName())) return d; throw new ReflectionError(concat("Unable to find property ", quote(propertyName), " in ", type.getName())); } static void verifyCorrectType(String name, Object target, Class expectedType, PropertyDescriptor descriptor) { Class actualType = descriptor.getPropertyType(); if (!expectedType.isAssignableFrom(actualType)) throw incorrectPropertyType(name, target, actualType, expectedType); } private static ReflectionError incorrectPropertyType(String name, Object target, Class actual, Class expected) { String typeName = target.getClass().getName(); String msg = concat("The type of the property ", quote(name), " in ", typeName, " should be <", expected.getName(), "> but was <", actual.getName(), ">"); throw new ReflectionError(msg); } private final String propertyName; private final Object target; private final PropertyDescriptor descriptor; private Invoker(String propertyName, Object target, PropertyDescriptor descriptor) { this.propertyName = propertyName; this.target = target; this.descriptor = descriptor; } /** * Sets a value in the property managed by this class. * @param value the value to set. * @throws ReflectionError if the given value cannot be set. */ public void set(T value) { try { descriptor.getWriteMethod().invoke(target, value); } catch (Exception e) { throw new ReflectionError(concat("Unable to update the value in property ", quote(propertyName)), e); } } /** * Returns the value of the property managed by this class. * @return the value of the property managed by this class. * @throws ReflectionError if the value of the property cannot be retrieved. */ @SuppressWarnings("unchecked") public T get() { try { return (T) descriptor.getReadMethod().invoke(target); } catch (Exception e) { throw new ReflectionError(concat("Unable to obtain the value in property " + quote(propertyName)), e); } } /** * Returns the "real" property managed by this class. * @return the "real" property managed by this class. */ public PropertyDescriptor info() { return descriptor; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/PropertyName.java000066400000000000000000000110631211245343200322710ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.beanproperty; import static org.fest.reflect.beanproperty.PropertyType.newPropertyType; import static org.fest.reflect.beanproperty.PropertyTypeRef.newPropertyTypeRef; import static org.fest.util.Strings.isEmpty; import org.fest.reflect.reference.TypeRef; /** * Understands the name of a property to access using Bean Introspection. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the property "name"
 *   String name = {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#get() get}();
 *
 *   // Sets the value of the property "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 *
 *   // Retrieves the value of the property "powers"
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#property(String) property}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link PropertyTypeRef#in(Object) in}(jedi).{@link Invoker#get() get}();
 *
 *   // Sets the value of the property "powers"
 *   List<String> powers = new ArrayList<String>();
 *   powers.add("heal");
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link PropertyTypeRef#in(Object) in}(jedi).{@link Invoker#set(Object) set}(powers);
 * 
*

* * @author Alex Ruiz * * @since 1.2 */ public final class PropertyName { /** * Creates a new {@link PropertyName}: the starting point of the fluent interface for accessing properties using * Bean Introspection. * @param name the name of the property to access using Bean Introspection. * @return the created PropertyName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static PropertyName startPropertyAccess(String name) { validateIsNotNullOrEmpty(name); return new PropertyName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the property to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the property to access should not be empty"); } private final String name; private PropertyName(String name) { this.name = name; } /** * Sets the type of the property to access. * @param the generic type of the property type. * @param type the type of the property to access. * @return a recipient for the property type. * @throws NullPointerException if the given type is null. */ public PropertyType ofType(Class type) { return newPropertyType(name, type); } /** * Sets the type reference of the property to access. This method reduces casting when the type of the property to access uses * generics. *

* For example: * *

   *   List<String> powers = {@link org.fest.reflect.core.Reflection#property(String) property}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link PropertyTypeRef#in(Object) in}(jedi).{@link Invoker#get() get}();
   * 
*

* @param the generic type of the property type. * @param type the type of the property to access. * @return a recipient for the property type. * @throws NullPointerException if the given type reference is null. */ public PropertyTypeRef ofType(TypeRef type) { return newPropertyTypeRef(name, type); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/PropertyType.java000066400000000000000000000051111211245343200323270ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.beanproperty; import static org.fest.reflect.beanproperty.Invoker.newInvoker; import org.fest.reflect.exception.ReflectionError; /** * Understands the type of a property to access using Bean Instrospection. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the property "name"
 *   String name = {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#get() get}();
 *
 *   // Sets the value of the property "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 * 
*

* * @param the generic type of the property. * * @author Alex Ruiz * * @since 1.2 */ public class PropertyType { static PropertyType newPropertyType(String name, Class type) { if (type == null) throw new NullPointerException("The type of the property to access should not be null"); return new PropertyType(name, type); } private final String name; private final Class type; private PropertyType(String name, Class type) { this.name = name; this.type = type; } /** * Returns a new property invoker. A property invoker is capable of accessing (read/write) the underlying property. * @param target the object containing the property of interest. * @return the created property invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a property with a matching name and type cannot be found. */ public Invoker in(Object target) { if (target == null) throw new NullPointerException("Target should not be null"); return newInvoker(name, type, target); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/PropertyTypeRef.java000066400000000000000000000054231211245343200327720ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.beanproperty; import static org.fest.reflect.beanproperty.Invoker.newInvoker; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.reference.TypeRef; /** * Understands the type of a property to access using Bean Instrospection. This implementation supports Java generics. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the property "powers"
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#property(String) property}("powers").{@link PropertyName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link #in(Object) in}(jedi).{@link Invoker#get() get}();
 *
 *   // Sets the value of the property "powers"
 *   List<String> powers = new ArrayList<String>();
 *   powers.add("heal");
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("powers").{@link PropertyName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link #in(Object) in}(jedi).{@link Invoker#set(Object) set}(powers);
 * 
*

* * @param the generic type of the property. * * @author Alex Ruiz * * @since 1.2 */ public class PropertyTypeRef { static PropertyTypeRef newPropertyTypeRef(String name, TypeRef type) { if (type == null) throw new NullPointerException("The type reference of the property to access should not be null"); return new PropertyTypeRef(name, type); } private final TypeRef type; private final String name; private PropertyTypeRef(String name, TypeRef type) { this.name = name; this.type = type; } /** * Returns a new property invoker. A property invoker is capable of accessing (read/write) the underlying property. * @param target the object containing the property of interest. * @return the created property invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a property with a matching name and type cannot be found. */ public Invoker in(Object target) { return newInvoker(name, type, target); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/beanproperty/package.html000066400000000000000000000037721211245343200312720ustar00rootroot00000000000000

Provides a "fluent" API for property access via the Bean Instrospection API.

Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

Here are some examples:

   // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;

   // Retrieves the value of the property "name"
   String name = {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link org.fest.reflect.beanproperty.PropertyName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.beanproperty.PropertyType#in(Object) in}(person).{@link org.fest.reflect.beanproperty.Invoker#get() get}();
   
   // Sets the value of the property "name" to "Yoda"
   {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link org.fest.reflect.beanproperty.PropertyName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.beanproperty.PropertyType#in(Object) in}(person).{@link org.fest.reflect.beanproperty.Invoker#set(Object) set}("Yoda");

fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/constructor/000077500000000000000000000000001211245343200266535ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/constructor/Invoker.java000066400000000000000000000071461211245343200311430ustar00rootroot00000000000000/* * Created on Oct 31, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.constructor; import static org.fest.reflect.util.Accessibles.makeAccessible; import static org.fest.reflect.util.Accessibles.setAccessibleIgnoringExceptions; import static org.fest.reflect.util.Throwables.targetOf; import static org.fest.util.Strings.concat; import java.lang.reflect.Constructor; import java.util.Arrays; import org.fest.reflect.exception.ReflectionError; /** * Understands the invocation of a constructor via Java Reflection. * @param the class in which the constructor is declared. *

* The following is an example of proper usage of the classes in this package: * *

 *   // Equivalent to call 'new Person()'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#in in}(Person.class).{@link #newInstance newInstance}();
 *
 *   // Equivalent to call 'new Person("Yoda")'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link ParameterTypes#in(Class) in}(Person.class).{@link #newInstance newInstance}("Yoda");
 * 
*

* * @author Alex Ruiz * @author Yvonne Wang */ public final class Invoker { public static Invoker newInvoker(Class target, Class... parameterTypes) { Constructor constructor = constructor(target, parameterTypes); return new Invoker(constructor); } private static Constructor constructor(Class target, Class... parameterTypes) { try { return target.getDeclaredConstructor(parameterTypes); } catch (Exception e) { throw new ReflectionError(concat("Unable to find constructor in type ", target.getName(), " with parameter types ", Arrays.toString(parameterTypes)), e); } } private final Constructor constructor; private Invoker(Constructor constructor) { this.constructor = constructor; } /** * Creates a new instance of T by calling a constructor with the given arguments. * @param args the arguments to pass to the constructor (can be zero or more). * @return the created instance of T. * @throws ReflectionError if a new instance cannot be created. */ public T newInstance(Object... args) { boolean accessible = constructor.isAccessible(); try { makeAccessible(constructor); T newInstance = constructor.newInstance(args); return newInstance; } catch (Throwable t) { Throwable cause = targetOf(t); if (cause instanceof RuntimeException) throw (RuntimeException) cause; throw new ReflectionError("Unable to create a new object from the enclosed constructor", cause); } finally { setAccessibleIgnoringExceptions(constructor, accessible); } } /** * Returns the "real" constructor managed by this class. * @return the "real" constructor managed by this class. */ public Constructor info() { return constructor; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/constructor/ParameterTypes.java000066400000000000000000000043651211245343200324730ustar00rootroot00000000000000/* * Created on Aug 17, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.constructor; import static org.fest.reflect.constructor.Invoker.newInvoker; /** * Understands the parameter types for the constructor to invoke. *

* The following is an example of proper usage of the classes in this package: * *

 *   // Equivalent to call 'new Person()'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#in in}(Person.class).{@link Invoker#newInstance newInstance}();
 *
 *   // Equivalent to call 'new Person("Yoda")'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link ParameterTypes#in(Class) in}(Person.class).{@link Invoker#newInstance newInstance}("Yoda");
 * 
*

* * @author Alex Ruiz * @author Yvonne Wang */ public final class ParameterTypes { static ParameterTypes newParameterTypes(Class[] parameterTypes) { if (parameterTypes == null) throw new NullPointerException("The array of parameter types should not be null"); return new ParameterTypes(parameterTypes); } private final Class[] parameterTypes; private ParameterTypes(Class[] parameterTypes) { this.parameterTypes = parameterTypes; } /** * Creates a new constructor invoker. * @param the generic type of the class containing the constructor to invoke. * @param target the the type of object that the constructor invoker will create. * @return the created constructor invoker. */ public Invoker in(Class target) { return newInvoker(target, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/constructor/TargetType.java000066400000000000000000000052071211245343200316120ustar00rootroot00000000000000/* * Created on Aug 17, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.constructor; import static org.fest.reflect.constructor.Invoker.newInvoker; import static org.fest.reflect.constructor.ParameterTypes.newParameterTypes; /** * Understands the type of object that the constructor will create. *

* The following is an example of proper usage of the classes in this package: * *

 *   // Equivalent to call 'new Person()'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#in in}(Person.class).{@link Invoker#newInstance newInstance}();
 *
 *   // Equivalent to call 'new Person("Yoda")'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link ParameterTypes#in(Class) in}(Person.class).{@link Invoker#newInstance newInstance}("Yoda");
 * 
*

* * @author Alex Ruiz * @author Yvonne Wang */ public final class TargetType { /** * Creates a new {@link TargetType}. * @return the created TargetType. */ public static TargetType startConstructorAccess() { return new TargetType(); } private TargetType() {} /** * Creates a new constructor invoker. * @param the generic type of the class containing the constructor to invoke. * @param target the the type of object that the constructor invoker will create. * @return the created constructor invoker. */ public Invoker in(Class target) { return newInvoker(target); } /** * Specifies the parameter types for the constructor to invoke. This method call is optional if the constructor to call does not * accept arguments. * @param parameterTypes the types of the parameters to pass to the constructor. * @return the created parameter type holder. * @throws NullPointerException if the given array is null. */ public ParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/constructor/package.html000066400000000000000000000037321211245343200311410ustar00rootroot00000000000000

Provides a "fluent" API for constructor invocation via the Java Reflection API.

Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

Here are some examples:

   // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;

   // Equivalent to call 'new Person()'
   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link org.fest.reflect.constructor.TargetType#in in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}();
   
   // Equivalent to call 'new Person("Yoda")'
   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link org.fest.reflect.constructor.TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link org.fest.reflect.constructor.ParameterTypes#in(Class) in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}("Yoda");

fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/core/000077500000000000000000000000001211245343200252165ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/core/Reflection.java000066400000000000000000000352321211245343200301600ustar00rootroot00000000000000/* * Created on Oct 31, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.core; import static org.fest.reflect.beanproperty.PropertyName.startPropertyAccess; import static org.fest.reflect.constructor.TargetType.startConstructorAccess; import static org.fest.reflect.field.FieldName.beginFieldAccess; import static org.fest.reflect.field.StaticFieldName.beginStaticFieldAccess; import static org.fest.reflect.innerclass.StaticInnerClassName.startStaticInnerClassAccess; import static org.fest.reflect.method.MethodName.startMethodAccess; import static org.fest.reflect.method.StaticMethodName.startStaticMethodAccess; import static org.fest.reflect.type.Type.newType; import org.fest.reflect.beanproperty.PropertyName; import org.fest.reflect.beanproperty.PropertyType; import org.fest.reflect.constructor.TargetType; import org.fest.reflect.field.FieldName; import org.fest.reflect.field.FieldTypeRef; import org.fest.reflect.field.StaticFieldName; import org.fest.reflect.field.StaticFieldType; import org.fest.reflect.field.StaticFieldTypeRef; import org.fest.reflect.innerclass.StaticInnerClassName; import org.fest.reflect.method.Invoker; import org.fest.reflect.method.MethodName; import org.fest.reflect.method.MethodReturnTypeRef; import org.fest.reflect.method.StaticMethodName; import org.fest.reflect.method.StaticMethodReturnTypeRef; import org.fest.reflect.reference.TypeRef; import org.fest.reflect.type.Type; /** * Understands the entry point for the classes in this package. *

* The following is an example of proper usage of the classes in this package: * *

 *   // Loads the class 'org.republic.Jedi'
 *   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#load() load}();
 *
 *   // Loads the class 'org.republic.Jedi' as 'org.republic.Person' (Jedi extends Person)
 *   Class<Person> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#loadAs(Class) loadAs}(Person.class);
 *
 *   // Loads the class 'org.republic.Jedi' using a custom class loader
 *   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link org.fest.reflect.type.TypeLoader#load() load}();
 *
 *   // Gets the inner class 'Master' in the declaring class 'Jedi':
 *   Class<?> masterClass = {@link org.fest.reflect.core.Reflection#staticInnerClass(String) staticInnerClass}("Master").{@link org.fest.reflect.innerclass.StaticInnerClassName#in(Class) in}(Jedi.class).{@link org.fest.reflect.innerclass.Invoker#get() get}();
 *
 *   // Equivalent to call 'new Person()'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#in in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}();
 *
 *   // Equivalent to call 'new Person("Yoda")'
 *   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link org.fest.reflect.constructor.ParameterTypes#in(Class) in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}("Yoda");
 *
 *   // Retrieves the value of the field "name"
 *   String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#get() get}();
 *
 *   // Sets the value of the field "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#set(Object) set}("Yoda");
 *
 *   // Retrieves the value of the field "powers"
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link FieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link FieldTypeRef#in(Object) in}(jedi).{@link org.fest.reflect.field.Invoker#get() get}();
 *
 *   // Equivalent to call 'person.setName("Luke")'
 *   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link org.fest.reflect.method.MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
 *                    .{@link org.fest.reflect.method.MethodParameterTypes#in(Object) in}(person)
 *                    .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}("Luke");
 *
 *   // Equivalent to call 'jedi.getPowers()'
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#method(String) method}("getPowers").{@link MethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
 *                                            .{@link MethodReturnTypeRef#in(Object) in}(person)
 *                                            .{@link Invoker#invoke(Object...) invoke}();
 *
 *   // Retrieves the value of the static field "count" in Person.class
 *   int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link org.fest.reflect.field.Invoker#get() get}();
 *
 *   // Sets the value of the static field "count" to 3 in Person.class
 *   {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link org.fest.reflect.field.Invoker#set(Object) set}(3);
 *
 *   // Retrieves the value of the static field "commonPowers" in Jedi.class
 *   List<String> commmonPowers = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link StaticFieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link org.fest.reflect.field.Invoker#get() get}();
 *
 *   // Equivalent to call 'person.concentrate()'
 *   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link org.fest.reflect.method.MethodName#in(Object) in}(person).{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
 *
 *   // Equivalent to call 'person.getName()'
 *   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link org.fest.reflect.method.MethodName#withReturnType(Class) withReturnType}(String.class)
 *                                  .{@link org.fest.reflect.method.MethodReturnType#in(Object) in}(person)
 *                                  .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
 *
 *   // Equivalent to call 'Jedi.setCommonPower("Jump")'
 *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("setCommonPower").{@link org.fest.reflect.method.StaticMethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
 *                                 .{@link org.fest.reflect.method.StaticMethodParameterTypes#in(Class) in}(Jedi.class)
 *                                 .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}("Jump");
 *
 *   // Equivalent to call 'Jedi.addPadawan()'
 *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("addPadawan").{@link org.fest.reflect.method.StaticMethodName#in(Class) in}(Jedi.class).{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
 *
 *   // Equivalent to call 'Jedi.commonPowerCount()'
 *   String name = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("commonPowerCount").{@link org.fest.reflect.method.StaticMethodName#withReturnType(Class) withReturnType}(String.class)
 *                                                 .{@link org.fest.reflect.method.StaticMethodReturnType#in(Class) in}(Jedi.class)
 *                                                 .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
 *
 *   // Equivalent to call 'Jedi.getCommonPowers()'
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
 *                                                        .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
 *                                                        .{@link Invoker#invoke(Object...) invoke}();
 *
 *   // Retrieves the value of the property "name"
 *   String name = {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link org.fest.reflect.beanproperty.Invoker#get() get}();
 *
 *   // Sets the value of the property "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#property(String) property}("name").{@link PropertyName#ofType(Class) ofType}(String.class).{@link PropertyType#in(Object) in}(person).{@link org.fest.reflect.beanproperty.Invoker#set(Object) set}("Yoda");
 * 
*

* * @author Alex Ruiz * @author Yvonne Wang * @author Ivan Hristov */ public final class Reflection { /** * Starting point of the fluent interface for loading a class dynamically. * @param name the name of the class to load. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. * @since 1.1 */ public static Type type(String name) { return newType(name); } /** * Starting point of the fluent interface for accessing static inner class via reflection. * @param name the name of the static inner class to access. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. * @since 1.1 */ public static StaticInnerClassName staticInnerClass(String name) { return startStaticInnerClassAccess(name); } /** * Starting point of the fluent interface for accessing fields via reflection.
* Nested field are supported with dot notation, e.g. "person.address.street". *

* Let's look how it works on an example : * *

   * Let's say we have the following simple service:
   * 
   * public class BusinessService {
   *   private NotificationService notificationService = new NotificationService();
   *   //... logic goes here
   * }
   *  
   * Where NotificationService is defined as follows:
   * 
   * public class NotificationService {
   *   private Logger logger = new Logger();
   *   private IClientStatusDao clientStatusDao = new ClientStatusDao();
   *   //... logic goes here
   * }
   * 
   * And our ClientStatusDao looks like:
   * 
   * public class ClientStatusDao implements IClientStatusDao {
   *   private final Session session = new SessionImpl();
   *    //... logic goes here
   * }
   *     
   * Let's say we want to change the {@code logger} field of {@code NotificationService} within our instance of {@code BusinessService}, we can do this:
   *  
   *   field("notificationService.logger").ofType(Logger.class).in(businessService).set(loggerMock);
   *  
   * You can also set the deeply nested {@code session} field within {@code ClientStatusDao} like this:
   * 
   *   field("notificationService.clientStatusDao.session").ofType(Session.class).in(businessService).set(sessionMock);
   * 
* * @param name the name of the field to access. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static FieldName field(String name) { return beginFieldAccess(name); } /** * Starting point of the fluent interface for accessing static fields via reflection. * @param name the name of the static field to access. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static StaticFieldName staticField(String name) { return beginStaticFieldAccess(name); } /** * Starting point of the fluent interface for invoking methods via reflection. * @param name the name of the method to invoke. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static MethodName method(String name) { return startMethodAccess(name); } /** * Starting point of the fluent interface for invoking static methods via reflection. * @param name the name of the static method to invoke. * @return the starting point of the static method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static StaticMethodName staticMethod(String name) { return startStaticMethodAccess(name); } /** * Starting point of the fluent interface for invoking constructors via reflection. * @return the starting point of the method chain. */ public static TargetType constructor() { return startConstructorAccess(); } /** * Starting point of the fluent interface for accessing properties via Bean Introspection. * @param name the name of the property to access. * @return the starting point of the method chain. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. * @since 1.2 */ public static PropertyName property(String name) { return startPropertyAccess(name); } private Reflection() {} } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/core/package.html000066400000000000000000000136711211245343200275070ustar00rootroot00000000000000

Provides a "fluent" API that makes usage of the Java Reflection API easier and improves code readability.

Here are some examples:

   // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;

   // Loads the class 'org.republic.Jedi'
   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link org.fest.reflect.type.Type#load() load}();
   
   // Loads the class 'org.republic.Jedi' as 'org.republic.Person' (Jedi extends Person)
   Class<Person> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link org.fest.reflect.type.Type#loadAs(Class) loadAs}(Person.class);

   // Loads the class 'org.republic.Jedi' using a custom class loader
   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link org.fest.reflect.type.Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link org.fest.reflect.type.TypeLoader#load() load}();

   // Gets the inner class 'Master' in the declaring class 'Jedi':
   Class<?> masterClass = {@link org.fest.reflect.core.Reflection#staticInnerClass(String) staticInnerClass}("Master").{@link org.fest.reflect.innerclass.StaticInnerClassName#in(Class) in}(Jedi.class).{@link org.fest.reflect.innerclass.Invoker#get() get}();

   // Equivalent to call 'new Person()'
   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link org.fest.reflect.constructor.TargetType#in in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}();
   
   // Equivalent to call 'new Person("Yoda")'
   Person p = {@link org.fest.reflect.core.Reflection#constructor() constructor}().{@link org.fest.reflect.constructor.TargetType#withParameterTypes(Class...) withParameterTypes}(String.class).{@link org.fest.reflect.constructor.ParameterTypes#in(Class) in}(Person.class).{@link org.fest.reflect.constructor.Invoker#newInstance(Object...) newInstance}("Yoda");
 
   // Retrieves the value of the field "name"
   String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#get() get}();
   
   // Sets the value of the field 'name' to "Yoda"
   {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#set(Object) set}("Yoda");
   
   // Equivalent to call 'jedi.getPowers()'
   List<String> powers = {@link org.fest.reflect.core.Reflection#method(String) method}("getPowers").{@link org.fest.reflect.method.MethodName#withReturnType(org.fest.reflect.reference.TypeRef) withReturnType}(new {@link org.fest.reflect.reference.TypeRef TypeRef}<List<String>>() {})
                                            .{@link org.fest.reflect.method.MethodReturnTypeRef#in(Object) in}(person)
                                            .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();   

   // Equivalent to call 'person.setName("Luke")'
   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link org.fest.reflect.method.MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
                    .{@link org.fest.reflect.method.MethodParameterTypes#in(Object) in}(person)
                    .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}("Luke");
 
   // Equivalent to call 'person.concentrate()'
   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link org.fest.reflect.method.MethodName#in(Object) in}(person).{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
   
   // Equivalent to call 'person.getName()'
   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link org.fest.reflect.method.MethodName#withReturnType(Class) withReturnType}(String.class)
                                  .{@link org.fest.reflect.method.MethodReturnType#in(Object) in}(person)
                                  .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();   
                                                  
   // Equivalent to call 'Jedi.getCommonPowers()'
   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link org.fest.reflect.method.StaticMethodName#withReturnType(org.fest.reflect.reference.TypeRef) withReturnType}(new {@link org.fest.reflect.reference.TypeRef TypeRef}<List<String>>() {})
                                                        .{@link org.fest.reflect.method.StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
                                                        .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();   

fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/exception/000077500000000000000000000000001211245343200262645ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/exception/ReflectionError.java000066400000000000000000000024321211245343200322340ustar00rootroot00000000000000/* * Created on Nov 16, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.exception; /** * Understands an error raised when using reflection. * * @author Alex Ruiz */ public final class ReflectionError extends RuntimeException { private static final long serialVersionUID = 1L; /** * Creates a new {@link ReflectionError}. * @param message the detail message. */ public ReflectionError(String message) { super(message); } /** * Creates a new {@link ReflectionError}. * @param message the detail message. * @param cause the cause of the exception. */ public ReflectionError(String message, Throwable cause) { super(message, cause); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/exception/package.html000066400000000000000000000016021211245343200305440ustar00rootroot00000000000000

Exceptions used in the FEST-Reflect module.

fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/000077500000000000000000000000001211245343200253515ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/DecoratedInvoker.java000066400000000000000000000143311211245343200314460ustar00rootroot00000000000000/* * Created on Mar 18, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import java.lang.reflect.Proxy; import org.fest.reflect.field.decorator.DecoratorInvocationHandler; import org.fest.reflect.field.decorator.RuntimeExceptionShield; /** * A decorated invoker allowing to ignore some exceptions or returning decorator result instead of field result. * @author Ivan Hristov */ public final class DecoratedInvoker { private final T target; private final T decorator; private final Invoker invoker; private final Class expectedType; private final DecoratorInvocationHandler decoratorInvocationHandler; static DecoratedInvoker newInvoker(T target, T decorator, Class expectedType, Invoker invoker, DecoratorInvocationHandler decoratorInvocationHandler) { return new DecoratedInvoker(target, decorator, expectedType, invoker, decoratorInvocationHandler); } private DecoratedInvoker(T target, T decorator, Class expectedType, Invoker invoker, DecoratorInvocationHandler decoratorInvocationHandler) { this.target = target; this.decorator = decorator; this.invoker = invoker; this.expectedType = expectedType; this.decoratorInvocationHandler = decoratorInvocationHandler; } /** * Ignores any {@link RuntimeException} which comes from the preceding decorator. * @return the DecoratedResultInvoker ignoring exceptions. */ public DecoratedInvoker ignoringDecoratorExceptions() { return ignoringDecoratorExceptionsOfType(RuntimeException.class); } /** * Ignores any exception of the {@code exceptionClass} type which comes from the preceding decorator. * @param exceptionClass the exception to ignore - usually a checked exception of decorator method * @return the DecoratedResultInvoker ignoring given exception type. */ public DecoratedInvoker ignoringDecoratorExceptionsOfType(Class exceptionClass) { RuntimeExceptionShield runtimeExceptionShield = new RuntimeExceptionShield(decorator, exceptionClass); @SuppressWarnings("unchecked") T exceptionSafeDecorator = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(),// new Class[] { expectedType }, runtimeExceptionShield); decoratorInvocationHandler.setDecorator(exceptionSafeDecorator); return newInvoker(target, exceptionSafeDecorator, expectedType, invoker, decoratorInvocationHandler); } /** * Specifies that the result from the decorator should be returned. *

* If {@link DecoratedInvoker#ignoringDecoratorExceptions() ignoringDecoratorExceptions()} is used in combination with this * method and an exception is thrown, the default value will be returned (as defined by JLS) for all primitives or null for all * non-primitive. *

* Example :
* If a {@link RuntimeException} is thrown while executing one of the decorated IExampleService field methods which * returns primitive boolean value, the default value false will be returned. * *

   * field("fieldName").ofType(IExampleService.class).in(target)
   *                   .postDecorateWith(postDecoratorService)
   *                   .returningDecoratorResult()
   *                   .ignoringDecoratorExceptions();
   * 
* In case of several decorators attached to a field, the result from the latest will be returned. *

* Example 1:
* The result from the preDecoratorService will be returned * *

   * field("fieldName").ofType(IExampleService.class).in(target)
   *                   .preDecorateWith(preDecoratorService)
   *                   .returningDecoratorResult();
   * 
* Example 2:
* The result from the postDecoratorService will be returned * *
   * field("fieldName").ofType(IExampleService.class).in(target)
   *                   .postDecorateWith(postDecoratorService)
   *                   .returningDecoratorResult();
   * 
* Example 3:
* The result from the preDecoratorService will be returned, since it's the latest attached decorator. * *
   * field("fieldName").ofType(IExampleService.class).in(target)
   *                   .postDecorateWith(postDecoratorService)
   *                   .returningDecoratorResult()
   *                   .preDecorateWith(preDecoratorService)
   *                   .returningDecoratorResult();
   * 
*/ public DecoratedInvoker returningDecoratorResult() { decoratorInvocationHandler.setReturnDecoratorResult(true); return newInvoker(target, decorator, expectedType, invoker, decoratorInvocationHandler); } /** * Adds a pre-decorator to an already decorated field. *

* Note that if there are more than one pre-decorators assigned to a field they will be executed starting from the last attached * decorator. * @param decorator which methods be called before the same targeted object methods * @return the {@link DecoratedInvoker} pre decorating the target field interface with given decorator. */ public DecoratedInvoker preDecorateWith(T decorator) { return invoker.preDecorateWith(decorator); } /** * Adds a post-decorator to an already decorated field *

* Note that if there are more than one post-decorators assigned to a field they will be executed starting from the first * attached decorator. * @param decorator which methods be called after the same targeted object methods * @return the {@link DecoratedInvoker} post decorating the target field interface with given decorator. */ public DecoratedInvoker postDecorateWith(T decorator) { return invoker.postDecorateWith(decorator); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/FieldName.java000066400000000000000000000112641211245343200300440ustar00rootroot00000000000000/* * Created on Aug 17, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.FieldType.newFieldType; import static org.fest.reflect.field.FieldTypeRef.newFieldTypeRef; import static org.fest.util.Strings.isEmpty; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.fest.reflect.reference.TypeRef; /** * Understands the name of a field to access using Java Reflection. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the field "name"
 *   String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#get() get}();
 *
 *   // Sets the value of the field "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 *
 *   // Retrieves the value of the field "powers"
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link FieldTypeRef#in(Object) in}(jedi).{@link Invoker#get() get}();
 *
 *   // Sets the value of the field "powers"
 *   List<String> powers = new ArrayList<String>();
 *   powers.add("heal");
 *   {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link FieldTypeRef#in(Object) in}(jedi).{@link Invoker#set(Object) set}(powers);
 * 
*

* * @author Alex Ruiz * @author Ivan Hristov */ public final class FieldName { private final String name; private final List path; /** * Creates a new {@link FieldName}: the starting point of the fluent interface for accessing fields using Java * Reflection. * @param name the name of the field to access using Java Reflection. * @return the created FieldName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static FieldName beginFieldAccess(String name) { validateIsNotNullOrEmpty(name); return new FieldName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the field to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the field to access should not be empty"); } private FieldName(String name) { this.path = new ArrayList(Arrays.asList(name.split("\\."))); path.remove(path.size() - 1); this.name = name.substring(name.lastIndexOf('.') + 1, name.length()); } /** * Sets the type of the field to access. * @param the generic type of the field type. * @param type the type of the field to access. * @return a recipient for the field type. * @throws NullPointerException if the given type is null. */ public FieldType ofType(Class type) { return newFieldType(name, type, path); } /** * Sets the type reference of the field to access. This method reduces casting when the type of the field to access uses * generics. *

* For example: * *

   *   List<String> powers = {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link FieldTypeRef#in(Object) in}(jedi).{@link Invoker#get() get}();
   * 
*

* @param the generic type of the field type. * @param type the type of the field to access. * @return a recipient for the field type. * @throws NullPointerException if the given type reference is null. * @since 1.1 */ public FieldTypeRef ofType(TypeRef type) { return newFieldTypeRef(name, type, path); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/FieldType.java000066400000000000000000000053571211245343200301130ustar00rootroot00000000000000/* * Created on Aug 17, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.Invoker.newInvoker; import java.util.List; import org.fest.reflect.exception.ReflectionError; /** * Understands the type of a field to access using Java Reflection. *

* The following is an example of proper usage of this class: * *

 * // Retrieves the value of the field "name"
 * String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#get() get}();
 *
 * // Sets the value of the field "name" to "Yoda"
 * {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 * 
*

* * @param the generic type of the field. * * @author Alex Ruiz * @author Ivan Hristov */ public class FieldType { private final List path; static FieldType newFieldType(String name, Class type, List path) { if (type == null) throw new NullPointerException("The type of the field to access should not be null"); return new FieldType(name, type, path); } private final String name; private final Class type; private FieldType(String name, Class type, List path) { this.name = name; this.type = type; this.path = path; } /** * Returns a new field access invoker, capable of accessing (read/write) the underlying field. * @param target the object containing the field of interest. * @return the created field access invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a field with a matching name and type cannot be found. */ public Invoker in(Object target) { Object nestedTarget = null; for (String fieldName : path) { nestedTarget = Invoker.getNestedField(fieldName, nestedTarget == null ? target : nestedTarget); } return newInvoker(name, type, nestedTarget == null ? target : nestedTarget); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/FieldTypeRef.java000066400000000000000000000060541211245343200305430ustar00rootroot00000000000000/* * Created on Jan 24, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.Invoker.newInvoker; import java.util.List; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.reference.TypeRef; /** * Understands the type of a field to access using Java Reflection. This implementation supports Java generics. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the field "powers"
 *   List<String> powers = {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link FieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link #in(Object) in}(jedi).{@link Invoker#get() get}();
 *
 *   // Sets the value of the field "powers"
 *   List<String> powers = new ArrayList<String>();
 *   powers.add("heal");
 *   {@link org.fest.reflect.core.Reflection#field(String) field}("powers").{@link FieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link #in(Object) in}(jedi).{@link Invoker#set(Object) set}(powers);
 * 
*

* * @param the generic type of the field. * * @author Alex Ruiz * @author Ivan Hristov * * @since 1.1 */ public class FieldTypeRef { static FieldTypeRef newFieldTypeRef(String name, TypeRef type, List path) { if (type == null) throw new NullPointerException("The type reference of the field to access should not be null"); return new FieldTypeRef(name, type, path); } private final String name; private final TypeRef type; private final List path; private FieldTypeRef(String name, TypeRef type, List path) { this.name = name; this.type = type; this.path = path; } /** * Returns a new field invoker. A field invoker is capable of accessing (read/write) the underlying field. * @param target the object containing the field of interest. * @return the created field invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a field with a matching name and type cannot be found. */ public Invoker in(Object target) { Object nestedTarget = null; for (String fieldName : path) { nestedTarget = Invoker.getNestedField(fieldName, nestedTarget == null ? target : nestedTarget); } return newInvoker(name, type, nestedTarget == null ? target : nestedTarget); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/Invoker.java000066400000000000000000000302531211245343200276340ustar00rootroot00000000000000/* * Created on Oct 31, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.util.Accessibles.*; import static org.fest.util.Arrays.array; import static org.fest.util.Strings.*; import java.lang.reflect.Field; import java.lang.reflect.Proxy; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.field.decorator.DecoratorInvocationHandler; import org.fest.reflect.field.decorator.PostDecorator; import org.fest.reflect.field.decorator.PreDecorator; import org.fest.reflect.reference.TypeRef; /** * Understands the use of reflection to access a field from an object. *

* The following is an example of proper usage of this class: * *

 *   // Retrieves the value of the field "name"
 *   String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#get() get}();
 * 
 *   // Sets the value of the field "name" to "Yoda"
 *   {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link FieldName#ofType(Class) ofType}(String.class).{@link FieldType#in(Object) in}(person).{@link Invoker#set(Object) set}("Yoda");
 * 
 *   // Retrieves the value of the static field "count"
 *   int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#get() get}();
 * 
 *   // Sets the value of the static field "count" to 3
 *   {@link org.fest.reflect.core.Reflection#staticField(String) field}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#set(Object) set}(3);
 * 
* *

* * @param the declared type for the field to access. * * @author Alex Ruiz * @author Ivan Hristov */ public final class Invoker { private final Object target; private final Field field; private final boolean accessible; private final Class expectedType; static Invoker newInvoker(String fieldName, TypeRef expectedType, Object target) { return createInvoker(fieldName, expectedType.rawType(), target); } static Invoker newInvoker(String fieldName, Class expectedType, Object target) { return createInvoker(fieldName, expectedType, target); } private static Invoker createInvoker(String fieldName, Class expectedType, Object target) { if (target == null) { throw new NullPointerException("Target should not be null"); } Field field = lookupInClassHierarchy(fieldName, typeOf(target)); verifyCorrectType(field, expectedType); return new Invoker(target, field, expectedType); } private static Class typeOf(Object target) { if (target instanceof Class) return (Class) target; return target.getClass(); } private static Field lookupInClassHierarchy(String fieldName, Class declaringType) { Field field = null; Class target = declaringType; while (target != null) { field = field(fieldName, target); if (field != null) break; target = target.getSuperclass(); } if (field != null) return field; throw new ReflectionError(concat("Unable to find field ", quote(fieldName), " in ", declaringType.getName())); } private static void verifyCorrectType(Field field, Class expectedType) { boolean isAccessible = field.isAccessible(); try { makeAccessible(field); Class actualType = field.getType(); if (!expectedType.isAssignableFrom(actualType)) throw incorrectFieldType(field, actualType, expectedType); } finally { setAccessibleIgnoringExceptions(field, isAccessible); } } private Invoker(Object target, Field field, Class expectedType) { this.target = target; this.field = field; this.expectedType = expectedType; accessible = field.isAccessible(); } private static Field field(String fieldName, Class declaringType) { try { return declaringType.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { return null; } } private static ReflectionError incorrectFieldType(Field field, Class actual, Class expected) { String fieldTypeName = field.getDeclaringClass().getName(); String message = concat("The type of the field ", quote(field.getName()), " in ", fieldTypeName, " should be <", expected.getName(), "> but was <", actual.getName(), ">"); throw new ReflectionError(message); } /** * Sets a value in the field managed by this class. * * @param value the value to set. * @throws ReflectionError if the given value cannot be set. */ public void set(T value) { try { setAccessible(field, true); field.set(target, value); } catch (Exception e) { throw new ReflectionError(concat("Unable to update the value in field ", quote(field.getName())), e); } finally { setAccessibleIgnoringExceptions(field, accessible); } } /** * Pre-decorates a targeted object's methods. *

* Each execution of a targeted object's method will be first performed on the same method of the {@code decorator} object. The * result (if any) from the invocation of the targeted object's method will be returned but you can choose to return the * decorator result if you want to. *

* Be aware: *

  • The type of a targeted object should be an interface for this functionality to work
  • *
  • Any exception caused by an invocation of a {@code decorator} object's method will result in disrupting the default * program's flow
  • *

    * Example: Assuming we have the following code: * *

       * interface IUploadFileService { 
       *   boolean upload(String file, String destination); 
       * }
       * 
       * public class FileManager {
       *     
       *   private IUploadFileService uploadFileService;
       *   private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/";
       * 
       *   public void manage(String fileName) {
       *     if( uploadFileService.upload(fileName, DEFAULT_DESTINATION) ) {
       *       System.out.println("File "+fileName+" sent to "+DEFAULT_DESTINATION);
       *     } else {
       *       System.out.println("Unable to sent "+fileName+" to "+DEFAULT_DESTINATION);
       *     } 
       *   }
       * }
       * 
    * * Let's say we want to decorate the uploadFileService.upload(...) part, so that additional functionality is executed * before the actual uploadFileService.upload(...) logic, the following code will do the job: * *
       * IUploadFileService uploadFileServiceDecorator = ...; 
       * FileManager fileManager = new FileManager();
       * 
       * field("uploadFileService").ofType(IUploadFileService.class)
       *                           .in(fileManager)
       *                           .preDecorateWith(uploadFileServiceDecorator);
       * 
    * However, if there is an exception when calling uploadFileServiceDecorator.upload(fileName, DEFAULT_DESTINATION) * the default program's flow will be interrupted and the uploadFileService.upload(fileName, DEFAULT_DESTINATION) * will not be executed. *

    * @param decorator which methods be called before the same targeted object methods * @return the {@link DecoratedInvoker} pre decorating the target field interface with given decorator. */ public DecoratedInvoker preDecorateWith(T decorator) { T target = get(); DecoratorInvocationHandler handler = new PreDecorator(target, decorator); @SuppressWarnings("unchecked") T field = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(), array(expectedType), handler); set(field); return DecoratedInvoker.newInvoker(target, decorator, expectedType, this, handler); } /** * Post-decorates a targeted object's methods. *

    * After each execution of a targeted object's method, the same method of the {@code decorator} object will be called. The * result (if any) from the invocation of the targeted object's method will be returned but you can choose to return the * decorator result if you want to. *

    * Be aware: *

  • The type of a targeted object should be an interface for this functionality to work
  • *
  • Any exception caused by an invocation of a {@code decorator} object's method will result in disrupting the default * program's flow
  • *

    * Example: Assuming we have the following code: * *

       * interface IUploadFileService { 
       *   boolean upload(String file, String destination); 
       * }
       * 
       * public class FileManager {
       *     
       *   private IUploadFileService uploadFileService;
       *   private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/";
       * 
       *   public void manage(String fileName) {
       *     if( uploadFileService.upload(fileName, DEFAULT_DESTINATION) ) {
       *       System.out.println("File "+fileName+" sent to "+DEFAULT_DESTINATION);
       *     } else {
       *       System.out.println("Unable to sent "+fileName+" to "+DEFAULT_DESTINATION);
       *     } 
       *   }
       * }
       * 
    * * Let's say we want to decorate the uploadFileService.upload(...) part, so that additional functionality is executed * before the actual uploadFileService.upload(...) logic, the following code will do the job: * *
       * IUploadFileService uploadFileServiceDecorator = ...; 
       * FileManager fileManager = new FileManager();
       * 
       * field("uploadFileService").ofType(IUploadFileService.class)
       *                           .in(fileManager)
       *                           .postDecorateWith(uploadFileServiceDecorator);
       * 
    * However, if there is an exception when calling uploadFileServiceDecorator.upload(fileName, DEFAULT_DESTINATION) * the default program's flow will be interrupted and the uploadFileService.upload(fileName, DEFAULT_DESTINATION) * will not be executed. *

    * @param decorator which methods be called after the same targeted object methods * @return the {@link DecoratedInvoker} post decorating the target field interface with given decorator. */ public DecoratedInvoker postDecorateWith(T decorator) { T target = get(); DecoratorInvocationHandler handler = new PostDecorator(target, decorator); @SuppressWarnings("unchecked") T field = (T) Proxy.newProxyInstance(decorator.getClass().getClassLoader(), array(expectedType), handler); set(field); return DecoratedInvoker.newInvoker(target, decorator, expectedType, this, handler); } /** * Returns the value of the field managed by this class. * * @return the value of the field managed by this class. * @throws ReflectionError if the value of the field cannot be retrieved. */ public T get() { return Invoker. get(field, accessible, target); } static Object getNestedField(String fieldName, Object target) { Field field = lookupInClassHierarchy(fieldName, typeOf(target)); return get(field, field.isAccessible(), target); } @SuppressWarnings("unchecked") private static T get(Field field, boolean accessible, Object target) { try { setAccessible(field, true); return (T) field.get(target); } catch (Exception e) { throw new ReflectionError(concat("Unable to obtain the value in field " + quote(field.getName())), e); } finally { setAccessibleIgnoringExceptions(field, accessible); } } /** * Returns the "real" field managed by this class. * * @return the "real" field managed by this class. */ public Field info() { return field; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/StaticFieldName.java000066400000000000000000000112311211245343200312060ustar00rootroot00000000000000/* * Created on Feb 5, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.StaticFieldType.newFieldType; import static org.fest.reflect.field.StaticFieldTypeRef.newFieldTypeRef; import static org.fest.util.Strings.isEmpty; import org.fest.reflect.reference.TypeRef; /** * Understands the name of a static field to access using Java Reflection. *

    * The following is an example of proper usage of this class: * *

     *   // Retrieves the value of the static field "count"
     *   int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#get() get}();
     *
     *   // Sets the value of the static field "count" to 3
     *   {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#set(Object) set}(3);
     *
     *   // Retrieves the value of the static field "commonPowers"
     *   List<String> commmonPowers = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link Invoker#get() get}();
     *
     *   // Sets the value of the static field "commonPowers"
     *   List<String> commonPowers = new ArrayList<String>();
     *   commonPowers.add("jump");
     *   {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link Invoker#set(Object) set}(commonPowers);
     * 
    *

    * * @author Alex Ruiz */ public final class StaticFieldName { /** * Creates a new {@link StaticFieldName}: the starting point of the fluent interface for accessing static fields * using Java Reflection. * @param name the name of the field to access using Java Reflection. * @return the created StaticFieldName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static StaticFieldName beginStaticFieldAccess(String name) { validateIsNotNullOrEmpty(name); return new StaticFieldName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the static field to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the static field to access should not be empty"); } private final String name; private StaticFieldName(String name) { this.name = name; } /** * Sets the type of the field to access. * @param the generic type of the field type. * @param type the type of the field to access. * @return a recipient for the field type. * @throws NullPointerException if the given type is null. */ public StaticFieldType ofType(Class type) { return newFieldType(name, type); } /** * Sets the type reference of the field to access. This method reduces casting when the type of the field to access uses * generics. *

    * For example: * *

       *   List<String> commmonPowers = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link #ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link Invoker#get() get}();
       * 
    *

    * @param the generic type of the field type. * @param type the type of the field to access. * @return a recipient for the field type. * @throws NullPointerException if the given type reference is null. */ public StaticFieldTypeRef ofType(TypeRef type) { return newFieldTypeRef(name, type); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/StaticFieldType.java000066400000000000000000000047621211245343200312620ustar00rootroot00000000000000/* * Created on Feb 5, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.Invoker.newInvoker; import org.fest.reflect.exception.ReflectionError; /** * Understands the type of a static field to access using Java Reflection. *

    * The following is an example of proper usage of this class: * *

     *   // Retrieves the value of the static field "count"
     *   int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#get() get}();
     *
     *   // Sets the value of the static field "count" to 3
     *   {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link StaticFieldName#ofType(Class) ofType}(int.class).{@link StaticFieldType#in(Class) in}(Person.class).{@link Invoker#set(Object) set}(3);
     * 
    *

    * * @param the generic type of the field. * * @author Alex Ruiz */ public class StaticFieldType { static StaticFieldType newFieldType(String name, Class type) { if (type == null) throw new NullPointerException("The type of the static field to access should not be null"); return new StaticFieldType(name, type); } private final String name; private final Class type; StaticFieldType(String name, Class type) { this.name = name; this.type = type; } /** * Returns a new field invoker. A field invoker is capable of accessing (read/write) the underlying field. * @param target the type containing the static field of interest. * @return the created field invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a static field with a matching name and type cannot be found. */ public Invoker in(Class target) { return newInvoker(name, type, target); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/StaticFieldTypeRef.java000066400000000000000000000055341211245343200317150ustar00rootroot00000000000000/* * Created on Feb 5, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.field.Invoker.newInvoker; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.reference.TypeRef; /** * Understands the type of a static field to access using Java Reflection. *

    * The following is an example of proper usage of this class: * *

     *   // Retrieves the value of the static field "commonPowers"
     *   List<String> commmonPowers = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link StaticFieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link Invoker#get() get}();
     *
     *   // Sets the value of the static field "commonPowers"
     *   List<String> commonPowers = new ArrayList<String>();
     *   commonPowers.add("jump");
     *   {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("commonPowers").{@link StaticFieldName#ofType(TypeRef) ofType}(new {@link TypeRef TypeRef}<List<String>>() {}).{@link StaticFieldTypeRef#in(Class) in}(Jedi.class).{@link Invoker#set(Object) set}(commonPowers);
     * 
    *

    * * @param the generic type of the field. * * @author Alex Ruiz * * @since 1.1 */ public class StaticFieldTypeRef { static StaticFieldTypeRef newFieldTypeRef(String name, TypeRef type) { if (type == null) throw new NullPointerException("The type reference of the static field to access should not be null"); return new StaticFieldTypeRef(name, type); } private final String name; private final TypeRef type; private StaticFieldTypeRef(String name, TypeRef type) { this.name = name; this.type = type; } /** * Returns a new field invoker. A field invoker is capable of accessing (read/write) the underlying field. * @param target the type containing the static field of interest. * @return the created field invoker. * @throws NullPointerException if the given target is null. * @throws ReflectionError if a static field with a matching name and type cannot be found. */ public Invoker in(Class target) { return newInvoker(name, type, target); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/decorator/000077500000000000000000000000001211245343200273335ustar00rootroot00000000000000DecoratorInvocationHandler.java000066400000000000000000000046221211245343200353750ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/decorator/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field.decorator; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * @author Ivan Hristov * */ public abstract class DecoratorInvocationHandler implements InvocationHandler { private final T target; private T decorator; private boolean returnDecoratorResult = false; public DecoratorInvocationHandler(T target, T decorator) { this.target = target; this.decorator = decorator; } public void setDecorator(T decorator) { this.decorator = decorator; } public T getTarget() { return target; } public T getDecorator() { return decorator; } public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object firstResult = null; try { firstResult = invokeFirst(method, args); } catch (InvocationTargetException e) { throw e.getCause(); } Object secondResult = null; try { secondResult = invokeSecond(method, args); } catch (InvocationTargetException e) { throw e.getCause(); } return getResult(firstResult, secondResult); } protected abstract Object invokeFirst(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException; protected abstract Object invokeSecond(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException; protected abstract Object getResult(Object firstResult, Object secondResult); public void setReturnDecoratorResult(boolean returnDecoratorResult) { this.returnDecoratorResult = returnDecoratorResult; } protected boolean shouldReturnDecoratorResult() { return returnDecoratorResult; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/decorator/PostDecorator.java000066400000000000000000000030721211245343200327700ustar00rootroot00000000000000/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field.decorator; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * A proxy for post-decorating a field * @author Ivan Hristov * */ public class PostDecorator extends DecoratorInvocationHandler { public PostDecorator(T target, T decorator) { super(target, decorator); } @Override protected Object invokeFirst(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(getTarget(), args); } @Override protected Object invokeSecond(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(getDecorator(), args); } @Override protected Object getResult(Object firstResult, Object secondResult) { return shouldReturnDecoratorResult() ? secondResult : firstResult; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/decorator/PreDecorator.java000066400000000000000000000030661211245343200325740ustar00rootroot00000000000000/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field.decorator; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * A proxy for pre-decorating a field * @author Ivan Hristov * */ public class PreDecorator extends DecoratorInvocationHandler { public PreDecorator(T target, T decorator) { super(target, decorator); } @Override protected Object invokeFirst(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(getDecorator(), args); } @Override protected Object invokeSecond(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { return method.invoke(getTarget(), args); } @Override protected Object getResult(Object firstResult, Object secondResult) { return shouldReturnDecoratorResult() ? firstResult : secondResult; } } RuntimeExceptionShield.java000066400000000000000000000041261211245343200345550ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/decorator/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field.decorator; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; /** * A proxy for shielding from exception * @author Ivan Hristov * */ public class RuntimeExceptionShield implements InvocationHandler { private static final Map, Object> DEFAULT_RETURN_VALUES = new HashMap, Object>(); private final Object target; private final Class exceptionClass; // static init - reference JLS { DEFAULT_RETURN_VALUES.put(byte.class, 0); DEFAULT_RETURN_VALUES.put(short.class, 0); DEFAULT_RETURN_VALUES.put(int.class, 0); DEFAULT_RETURN_VALUES.put(long.class, 0L); DEFAULT_RETURN_VALUES.put(float.class, 0f); DEFAULT_RETURN_VALUES.put(double.class, 0d); DEFAULT_RETURN_VALUES.put(char.class, '\u0000'); DEFAULT_RETURN_VALUES.put(boolean.class, false); } public RuntimeExceptionShield(Object target, Class exceptionClass) { this.target = target; this.exceptionClass = exceptionClass; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return method.invoke(target, args); } catch (InvocationTargetException e) { if (!(e.getCause().getClass() == exceptionClass)) throw e.getCause(); // shield from specified exceptions } return DEFAULT_RETURN_VALUES.get(method.getReturnType()); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/field/package.html000066400000000000000000000051621211245343200276360ustar00rootroot00000000000000

    Provides a "fluent" API for field access via the Java Reflection API.

    Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

    Here are some examples:

       // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;
    
       // Retrieves the value of the field "name"
       String name = {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#get() get}();
       
       // Sets the value of the field "name" to "Yoda"
       {@link org.fest.reflect.core.Reflection#field(String) field}("name").{@link org.fest.reflect.field.FieldName#ofType(Class) ofType}(String.class).{@link org.fest.reflect.field.FieldType#in(Object) in}(person).{@link org.fest.reflect.field.Invoker#set(Object) set}("Yoda");
    
       // Retrieves the value of the static field "count"
       int count = {@link org.fest.reflect.core.Reflection#staticField(String) staticField}("count").{@link org.fest.reflect.field.StaticFieldName#ofType(Class) ofType}(int.class).{@link org.fest.reflect.field.StaticFieldType#in(Class) in}(Person.class).{@link org.fest.reflect.field.Invoker#get() get}();
       
       // Sets the value of the static field "count" to 3
       {@link org.fest.reflect.core.Reflection#staticField(String) field}("count").{@link org.fest.reflect.field.StaticFieldName#ofType(Class) ofType}(int.class).{@link org.fest.reflect.field.StaticFieldType#in(Class) in}(Person.class).{@link org.fest.reflect.field.Invoker#set(Object) set}(3);
    

    fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/innerclass/000077500000000000000000000000001211245343200264275ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/innerclass/Invoker.java000066400000000000000000000042411211245343200307100ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.innerclass; import static org.fest.util.Strings.concat; import org.fest.reflect.exception.ReflectionError; /** * Understands how to obtain a reference to a static inner class. * * @author Alex Ruiz * * @since 1.1 */ public class Invoker { static Invoker newInvoker(Class declaringClass, String innerClassName) { if (declaringClass == null) throw new NullPointerException("The declaring class should not be null"); return new Invoker(declaringClass, innerClassName); } private final Class declaringClass; private final String innerClassName; private Invoker(Class declaringClass, String innerClassName) { this.declaringClass = declaringClass; this.innerClassName = innerClassName; } /** * Returns a reference to the static inner class with the specified name in the specified declaring class. * @return a reference to the static inner class with the specified name in the specified declaring class. * @throws ReflectionError if the static inner class does not exist (since 1.2). */ public Class get() { String namespace = declaringClass.getName(); for (Class innerClass : declaringClass.getDeclaredClasses()) if (innerClass.getName().equals(expectedInnerClassName(namespace))) return innerClass; throw new ReflectionError(concat("The static inner class <", innerClassName, "> cannot be found in ", declaringClass.getName())); } private String expectedInnerClassName(String namespace) { return concat(namespace, "$", innerClassName); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/innerclass/StaticInnerClassName.java000066400000000000000000000055611211245343200333130ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.innerclass; import static org.fest.reflect.innerclass.Invoker.newInvoker; import static org.fest.util.Strings.isEmpty; /** * Understands the name of a static inner class. *

    * Let's assume we have the class Jedi, which contains two static inner classes: Master and * Padawan. * *

     * public class Jedi {
     *
     *   public static class Master {}
     *
     *   public static class Padawan {}
     * }
     * 
    *

    *

    * The following example shows how to get a reference to the inner class Master: * *

     * Class<?> masterClass = {@link org.fest.reflect.core.Reflection#staticInnerClass(String) staticInnerClass}("Master").{@link org.fest.reflect.innerclass.StaticInnerClassName#in(Class) in}(Jedi.class).{@link org.fest.reflect.innerclass.Invoker#get() get}();
     * 
    *

    * * @author Alex Ruiz * * @since 1.1 */ public final class StaticInnerClassName { /** * Creates a new {@link StaticInnerClassName}. * @param name the name of the static inner class to obtain. * @return the created StaticInnerClassName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static StaticInnerClassName startStaticInnerClassAccess(String name) { validateIsNotNullOrEmpty(name); return new StaticInnerClassName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the static inner class to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the static inner class to access should not be empty"); } private final String name; private StaticInnerClassName(String name) { this.name = name; } /** * Specifies the declaring class of the static inner class to obtain. * @param declaringClass the declaring class. * @return an object responsible for obtaining a reference to a static inner class. * @throws NullPointerException if the given declaring class is null. */ public Invoker in(Class declaringClass) { return newInvoker(declaringClass, name); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/innerclass/package.html000066400000000000000000000031721211245343200307130ustar00rootroot00000000000000

    Provides a "fluent" API for accessing static inner classes via the Java Reflection API.

    Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

    Here are some examples:

       // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;
    
       // Gets the inner class 'Master' in the declaring class 'Jedi':
       Class<?> masterClass = {@link org.fest.reflect.core.Reflection#staticInnerClass(String) staticInnerClass}("Master").{@link org.fest.reflect.innerclass.StaticInnerClassName#in(Class) in}(Jedi.class).{@link org.fest.reflect.innerclass.Invoker#get() get}();
    

    fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/000077500000000000000000000000001211245343200255465ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/Invoker.java000066400000000000000000000120231211245343200300240ustar00rootroot00000000000000/* * Created on Oct 31, 2006 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.util.Accessibles.makeAccessible; import static org.fest.reflect.util.Accessibles.setAccessibleIgnoringExceptions; import static org.fest.reflect.util.Throwables.targetOf; import static org.fest.util.Arrays.format; import static org.fest.util.Strings.concat; import static org.fest.util.Strings.quote; import java.lang.reflect.Method; import org.fest.reflect.exception.ReflectionError; /** * Understands the use of reflection to access a method from an object. *

    * *

     *   // Equivalent to call 'person.setName("Luke")'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                    .{@link MethodParameterTypes#in(Object) in}(person)
     *                    .{@link Invoker#invoke(Object...) invoke}("Luke");
     *
     *   // Equivalent to call 'person.concentrate()'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link MethodName#in(Object) in}(person).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'person.getName()'
     *   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link MethodName#withReturnType(Class) withReturnType}(String.class)
     *                                  .{@link MethodReturnType#in(Object) in}(person)
     *                                  .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the return type of the method invocation. * * @author Yvonne Wang */ public final class Invoker { static Invoker newInvoker(String methodName, Object target, Class... parameterTypes) { return createInvoker(methodName, target, parameterTypes); } private static Invoker createInvoker(String methodName, Object target, Class... parameterTypes) { if (target == null) throw new NullPointerException("Target should not be null"); Method method = lookupInClassHierarchy(methodName, typeOf(target), parameterTypes); return new Invoker(target, method); } private static Class typeOf(Object target) { if (target instanceof Class) return (Class) target; return target.getClass(); } private static Method lookupInClassHierarchy(String methodName, Class targetType, Class[] parameterTypes) { Method method = null; Class type = targetType; while (type != null) { method = method(methodName, type, parameterTypes); if (method != null) break; type = type.getSuperclass(); } if (method == null) throw new ReflectionError(concat("Unable to find method ", quote(methodName), " in ", targetType.getName(), " with parameter type(s) ", format(parameterTypes))); return method; } private static Method method(String methodName, Class type, Class[] parameterTypes) { try { return type.getDeclaredMethod(methodName, parameterTypes); } catch (SecurityException e) { return null; } catch (NoSuchMethodException e) { return null; } } private final Object target; private final Method method; private Invoker(Object target, Method method) { this.target = target; this.method = method; } /** * Invokes the method managed by this class using the given arguments. * @param args the arguments to use to call the method managed by this class. * @return the result of the method call. * @throws ReflectionError if the method cannot be invoked. */ @SuppressWarnings("unchecked") public T invoke(Object... args) { boolean accessible = method.isAccessible(); try { makeAccessible(method); return (T) method.invoke(target, args); } catch (Throwable t) { Throwable cause = targetOf(t); if (cause instanceof RuntimeException) throw (RuntimeException) cause; throw cannotInvokeMethod(cause, args); } finally { setAccessibleIgnoringExceptions(method, accessible); } } private ReflectionError cannotInvokeMethod(Throwable cause, Object... args) { String message = concat("Unable to invoke method ", quote(method.getName()), " with arguments ", format(args)); throw new ReflectionError(message, cause); } /** * Returns the "real" method managed by this class. * @return the "real" method managed by this class. */ public java.lang.reflect.Method info() { return method; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/MethodName.java000066400000000000000000000127771211245343200304500ustar00rootroot00000000000000/* * Created on Aug 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.MethodParameterTypes.newParameterTypes; import static org.fest.reflect.method.MethodReturnType.newReturnType; import static org.fest.reflect.method.MethodReturnTypeRef.newReturnTypeRef; import static org.fest.util.Strings.isEmpty; import org.fest.reflect.reference.TypeRef; /** * Understands the name of a method to invoke using Java Reflection. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'person.setName("Luke")'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                    .{@link MethodParameterTypes#in(Object) in}(person)
     *                    .{@link Invoker#invoke(Object...) invoke}("Luke");
     *
     *   // Equivalent to call 'person.concentrate()'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link MethodName#in(Object) in}(person).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'person.getName()'
     *   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link MethodName#withReturnType(Class) withReturnType}(String.class)
     *                                  .{@link MethodReturnType#in(Object) in}(person)
     *                                  .{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'jedi.getPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#method(String) method}("getPowers").{@link MethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                            .{@link MethodReturnTypeRef#in(Object) in}(person)
     *                                            .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @author Yvonne Wang * @author Alex Ruiz */ public final class MethodName { /** * Creates a new {@link MethodName}: the starting point of the fluent interface for accessing methods using Java * Reflection. * @param name the name of the method to invoke using Java Reflection. * @return the created MethodName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static MethodName startMethodAccess(String name) { validateIsNotNullOrEmpty(name); return new MethodName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the method to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the method to access should not be empty"); } private final String name; private MethodName(String name) { this.name = name; } /** * Specifies the return type of the method to invoke. This method call is optional if the return type of the method to invoke is * void. * @param the generic type of the method's return type. * @param type the return type of the method to invoke. * @return the created return type holder. * @throws NullPointerException if the given type is null. */ public MethodReturnType withReturnType(Class type) { return newReturnType(name, type); } /** * Specifies the return type reference of the method to invoke. This method call is optional if the return type of the method to * invoke is void. * @param the generic type of the method's return type. * @param type the return type reference of the method to invoke. * @return the created return type holder. * @throws NullPointerException if the given type reference is null. * @since 1.1 */ public MethodReturnTypeRef withReturnType(TypeRef type) { return newReturnTypeRef(name, type); } /** * Specifies the parameter types of the method to invoke. This method call is optional if the method to invoke does not take * arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public MethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } /** * Creates a new invoker for a method that takes no parameters and return value void. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Object target) { return newInvoker(name, target); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/MethodParameterTypes.java000066400000000000000000000054641211245343200325300ustar00rootroot00000000000000/* * Created on Aug 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; /** * Understands the parameter types of the method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'person.setName("Luke")'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                    .{@link MethodParameterTypes#in(Object) in}(person)
     *                    .{@link Invoker#invoke(Object...) invoke}("Luke");
     *
     *   // Equivalent to call 'person.concentrate()'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link MethodName#in(Object) in}(person).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'person.getName()'
     *   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link MethodName#withReturnType(Class) withReturnType}(String.class)
     *                                  .{@link MethodReturnType#in(Object) in}(person)
     *                                  .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the method's return type. * * @author Yvonne Wang * @author Alex Ruiz */ public final class MethodParameterTypes { private final String name; private final Class[] parameterTypes; static MethodParameterTypes newParameterTypes(String name, Class[] parameterTypes) { if (parameterTypes == null) throw new NullPointerException("The array of parameter types for the method to access should not be null"); return new MethodParameterTypes(parameterTypes, name); } private MethodParameterTypes(Class[] parameterTypes, String name) { this.name = name; this.parameterTypes = parameterTypes; } /** * Creates a new method invoker. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Object target) { return newInvoker(name, target, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/MethodReturnType.java000066400000000000000000000062411211245343200316760ustar00rootroot00000000000000/* * Created on Aug 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.MethodParameterTypes.newParameterTypes; /** * Understands the return type of the method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'person.setName("Luke")'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                    .{@link MethodParameterTypes#in(Object) in}(person)
     *                    .{@link Invoker#invoke(Object...) invoke}("Luke");
     *
     *   // Equivalent to call 'person.concentrate()'
     *   {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link MethodName#in(Object) in}(person).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'person.getName()'
     *   String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link MethodName#withReturnType(Class) withReturnType}(String.class)
     *                                  .{@link MethodReturnType#in(Object) in}(person)
     *                                  .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the method's return type. * * @author Yvonne Wang * @author Alex Ruiz */ public class MethodReturnType { static MethodReturnType newReturnType(String name, Class type) { if (type == null) throw new NullPointerException("The return type of the method to access should not be null"); return new MethodReturnType(name); } private final String name; private MethodReturnType(String name) { this.name = name; } /** * Creates a new method invoker. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Object target) { return newInvoker(name, target); } /** * Specifies the parameter types of the method to invoke. This method call is optional if the method to invoke does not take * arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public MethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/MethodReturnTypeRef.java000066400000000000000000000054021211245343200323310ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.MethodParameterTypes.newParameterTypes; import org.fest.reflect.reference.TypeRef; /** * Understands the return type reference of the method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'jedi.getPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#method(String) method}("getPowers").{@link MethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                            .{@link MethodReturnTypeRef#in(Object) in}(person)
     *                                            .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the method's return type reference. * * @author Alex Ruiz * * @since 1.1 */ public class MethodReturnTypeRef { static MethodReturnTypeRef newReturnTypeRef(String name, TypeRef type) { if (type == null) throw new NullPointerException("The return type reference of the method to access should not be null"); return new MethodReturnTypeRef(name); } private final String name; private MethodReturnTypeRef(String name) { this.name = name; } /** * Creates a new method invoker. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Object target) { return newInvoker(name, target); } /** * Specifies the parameter types of the method to invoke. This method call is optional if the method to invoke does not take * arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public MethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/StaticMethodName.java000066400000000000000000000134741211245343200316130ustar00rootroot00000000000000/* * Created on Feb 20, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.StaticMethodParameterTypes.newParameterTypes; import static org.fest.reflect.method.StaticMethodReturnType.newReturnType; import static org.fest.reflect.method.StaticMethodReturnTypeRef.newReturnTypeRef; import static org.fest.util.Strings.isEmpty; import org.fest.reflect.reference.TypeRef; /** * Understands the name of a static method to invoke using Java Reflection. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'Jedi.setCommonPower("Jump")'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("setCommonPower").{@link StaticMethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                                 .{@link StaticMethodParameterTypes#in(Class) in}(Jedi.class)
     *                                 .{@link Invoker#invoke(Object...) invoke}("Jump");
     *
     *   // Equivalent to call 'Jedi.addPadawan()'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("addPadawan").{@link StaticMethodName#in(Class) in}(Jedi.class).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.commonPowerCount()'
     *   String name = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("commonPowerCount").{@link StaticMethodName#withReturnType(Class) withReturnType}(String.class)
     *                                                 .{@link StaticMethodReturnType#in(Class) in}(Jedi.class)
     *                                                 .{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.getCommonPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                                        .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
     *                                                        .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @author Alex Ruiz */ public final class StaticMethodName { /** * Creates a new {@link StaticMethodName}: the starting point of the fluent interface for accessing static methods * using Java Reflection. * @param name the name of the method to access using Java Reflection. * @return the created StaticMethodName. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static StaticMethodName startStaticMethodAccess(String name) { validateIsNotNullOrEmpty(name); return new StaticMethodName(name); } private static void validateIsNotNullOrEmpty(String name) { if (name == null) throw new NullPointerException("The name of the static method to access should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the static method to access should not be empty"); } private final String name; private StaticMethodName(String name) { this.name = name; } /** * Specifies the return type of the static method to invoke. This method call is optional if the return type of the method to * invoke is void. * @param the generic type of the method's return type. * @param type the return type of the method to invoke. * @return the created return type holder. * @throws NullPointerException if the given type is null. */ public StaticMethodReturnType withReturnType(Class type) { return newReturnType(name, type); } /** * Specifies the return type reference of the static method to invoke. This method call is optional if the return type of the * method to invoke is void. * @param the generic type of the method's return type. * @param type the return type reference of the method to invoke. * @return the created return type holder. * @throws NullPointerException if the given type reference is null. */ public StaticMethodReturnTypeRef withReturnType(TypeRef type) { return newReturnTypeRef(name, type); } /** * Specifies the parameter types of the static method to invoke. This method call is optional if the method to invoke does not * take arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public StaticMethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } /** * Creates a new invoker for a static method that takes no parameters and return value void. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Class target) { return newInvoker(name, target); } } StaticMethodParameterTypes.java000066400000000000000000000070501211245343200336120ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/* * Created on Aug 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import org.fest.reflect.reference.TypeRef; /** * Understands the parameter types of the static method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'Jedi.setCommonPower("Jump")'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("setCommonPower").{@link StaticMethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                                 .{@link StaticMethodParameterTypes#in(Class) in}(Jedi.class)
     *                                 .{@link Invoker#invoke(Object...) invoke}("Jump");
     *
     *   // Equivalent to call 'Jedi.addPadawan()'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("addPadawan").{@link StaticMethodName#in(Class) in}(Jedi.class).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.commonPowerCount()'
     *   String name = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("commonPowerCount").{@link StaticMethodName#withReturnType(Class) withReturnType}(String.class)
     *                                                 .{@link StaticMethodReturnType#in(Class) in}(Jedi.class)
     *                                                 .{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.getCommonPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                                        .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
     *                                                        .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the static method's return type. * * @author Alex Ruiz */ public final class StaticMethodParameterTypes { static StaticMethodParameterTypes newParameterTypes(String name, Class[] parameterTypes) { if (parameterTypes == null) throw new NullPointerException("The array of parameter types for the static method to access should not be null"); return new StaticMethodParameterTypes(name, parameterTypes); } private final String name; private final Class[] parameterTypes; private StaticMethodParameterTypes(String name, Class[] parameterTypes) { this.name = name; this.parameterTypes = parameterTypes; } /** * Creates a new method invoker. * @param target the class containing the static method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Class target) { return newInvoker(name, target, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/StaticMethodReturnType.java000066400000000000000000000076421211245343200330540ustar00rootroot00000000000000/* * Created on Aug 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.StaticMethodParameterTypes.newParameterTypes; import org.fest.reflect.reference.TypeRef; /** * Understands the return type of the static method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'Jedi.setCommonPower("Jump")'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("setCommonPower").{@link StaticMethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
     *                                 .{@link StaticMethodParameterTypes#in(Class) in}(Jedi.class)
     *                                 .{@link Invoker#invoke(Object...) invoke}("Jump");
     *
     *   // Equivalent to call 'Jedi.addPadawan()'
     *   {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("addPadawan").{@link StaticMethodName#in(Class) in}(Jedi.class).{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.commonPowerCount()'
     *   String name = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("commonPowerCount").{@link StaticMethodName#withReturnType(Class) withReturnType}(String.class)
     *                                                 .{@link StaticMethodReturnType#in(Class) in}(Jedi.class)
     *                                                 .{@link Invoker#invoke(Object...) invoke}();
     *
     *   // Equivalent to call 'Jedi.getCommonPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                                        .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
     *                                                        .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the static method's return type. * * @author Alex Ruiz */ public class StaticMethodReturnType { static StaticMethodReturnType newReturnType(String name, Class type) { if (type == null) throw new NullPointerException("The return type of the static method to access should not be null"); return new StaticMethodReturnType(name); } private final String name; private StaticMethodReturnType(String name) { this.name = name; } /** * Creates a new method invoker. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Class target) { return newInvoker(name, target); } /** * Specifies the parameter types of the static method to invoke. This method call is optional if the method to invoke does not * take arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public StaticMethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/StaticMethodReturnTypeRef.java000066400000000000000000000055351211245343200335100ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.method.Invoker.newInvoker; import static org.fest.reflect.method.StaticMethodParameterTypes.newParameterTypes; import org.fest.reflect.reference.TypeRef; /** * Understands the return type of the static method to invoke. *

    * The following is an example of proper usage of this class: * *

     *   // Equivalent to call 'Jedi.getCommonPowers()'
     *   List<String> powers = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("getCommonPowers").{@link StaticMethodName#withReturnType(TypeRef) withReturnType}(new {@link TypeRef TypeRef}<List<String>>() {})
     *                                            .{@link StaticMethodReturnTypeRef#in(Class) in}(Jedi.class)
     *                                            .{@link Invoker#invoke(Object...) invoke}();
     * 
    *

    * * @param the generic type of the static method's return type. * * @author Alex Ruiz * * @since 1.1 */ public class StaticMethodReturnTypeRef { static StaticMethodReturnTypeRef newReturnTypeRef(String name, TypeRef type) { if (type == null) throw new NullPointerException("The return type reference of the static method to access should not be null"); return new StaticMethodReturnTypeRef(name); } private final String name; private StaticMethodReturnTypeRef(String name) { this.name = name; } /** * Creates a new method invoker. * @param target the object containing the method to invoke. * @return the created method invoker. * @throws NullPointerException if the given target is null. */ public Invoker in(Class target) { return newInvoker(name, target); } /** * Specifies the parameter types of the static method to invoke. This method call is optional if the method to invoke does not * take arguments. * @param parameterTypes the parameter types of the method to invoke. * @return the created parameter types holder. * @throws NullPointerException if the array of parameter types is null. */ public StaticMethodParameterTypes withParameterTypes(Class... parameterTypes) { return newParameterTypes(name, parameterTypes); } }fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/method/package.html000066400000000000000000000072561211245343200300410ustar00rootroot00000000000000

    Provides a "fluent" API for method invocation via the Java Reflection API.

    Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

    Here are some examples:

       // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;
    
       // Equivalent to call 'person.setName("Luke")'
       {@link org.fest.reflect.core.Reflection#method(String) method}("setName").{@link org.fest.reflect.method.MethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
                        .{@link org.fest.reflect.method.MethodParameterTypes#in(Object) in}(person)
                        .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}("Luke");
     
       // Equivalent to call 'person.concentrate()'
       {@link org.fest.reflect.core.Reflection#method(String) method}("concentrate").{@link org.fest.reflect.method.MethodName#in(Object) in}(person).{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
       
       // Equivalent to call 'person.getName()'
       String name = {@link org.fest.reflect.core.Reflection#method(String) method}("getName").{@link org.fest.reflect.method.MethodName#withReturnType(Class) withReturnType}(String.class)
                                      .{@link org.fest.reflect.method.MethodReturnType#in(Object) in}(person)
                                      .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();   
    
       // Equivalent to call 'Jedi.class.setCommonPower("Jump")'
       {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("setCommonPower").{@link org.fest.reflect.method.StaticMethodName#withParameterTypes(Class...) withParameterTypes}(String.class)
                                     .{@link org.fest.reflect.method.StaticMethodParameterTypes#in(Class) in}(Jedi.class)
                                     .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}("Jump");
    
       // Equivalent to call 'Jedi.class.addPadawan()'
       {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("addPadawan").{@link org.fest.reflect.method.StaticMethodName#in(Class) in}(Jedi.class).{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
    
       // Equivalent to call 'Jedi.class.commonPowerCount()'
       String name = {@link org.fest.reflect.core.Reflection#staticMethod(String) staticMethod}("commonPowerCount").{@link org.fest.reflect.method.StaticMethodName#withReturnType(Class) withReturnType}(String.class)
                                                     .{@link org.fest.reflect.method.StaticMethodReturnType#in(Class) in}(Jedi.class)
                                                     .{@link org.fest.reflect.method.Invoker#invoke(Object...) invoke}();
    

    fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/reference/000077500000000000000000000000001211245343200262245ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/reference/TypeRef.java000066400000000000000000000036071211245343200304530ustar00rootroot00000000000000/* * Created on Jan 24, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.reference; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import org.fest.reflect.exception.ReflectionError; /** * Understands a references a generic type. Based on Neal Gafter's * TypeReference. * @param the generic type in this reference. * * @author crazybob@google.com (Bob Lee) * @author Alex Ruiz * * @since 1.1 */ public abstract class TypeRef { private final Class rawType; /** * Creates a new {@link TypeRef}. * @throws ReflectionError if the generic type of this reference is missing type parameter. */ public TypeRef() { Type superclass = getClass().getGenericSuperclass(); if (superclass instanceof Class) throw new ReflectionError("Missing type parameter."); Type type = ((ParameterizedType) superclass).getActualTypeArguments()[0]; rawType = type instanceof Class ? (Class) type : (Class) ((ParameterizedType) type).getRawType(); } /** * Returns the raw type of the generic type in this reference. * @return the raw type of the generic type in this reference. */ public final Class rawType() { return rawType; } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/reference/package.html000066400000000000000000000020451211245343200305060ustar00rootroot00000000000000

    Provides support to use Java Generics overcoming the limitations of erasure. Based on Neal Gafter's Super Type Tokens.

    fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/type/000077500000000000000000000000001211245343200252475ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/type/Type.java000066400000000000000000000107331211245343200270370ustar00rootroot00000000000000/* * Created on Jan 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.type; import org.fest.reflect.exception.ReflectionError; import static org.fest.reflect.type.TypeLoader.newLoader; import static org.fest.util.Strings.isEmpty; /** * Understands loading a class dynamically. *

    * The following is an example of proper usage of this class: * *

     *   // Loads the class 'org.republic.Jedi'
     *   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#load() load}();
     *
     *   // Loads the class 'org.republic.Jedi' as 'org.republic.Person' (Jedi extends Person)
     *   Class<Person> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#loadAs(Class) loadAs}(Person.class);
     *
     *   // Loads the class 'org.republic.Jedi' using a custom class loader
     *   Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link org.fest.reflect.type.TypeLoader#load() load}();
     * 
    *

    * * @author Alex Ruiz * * @since 1.1 */ public final class Type { /** * Creates a new {@link Type}: the starting point of the fluent interface for loading classes dynamically. * @param name the name of the class to load. * @return the created Type. * @throws NullPointerException if the given name is null. * @throws IllegalArgumentException if the given name is empty. */ public static Type newType(String name) { if (name == null) throw new NullPointerException("The name of the class to load should not be null"); if (isEmpty(name)) throw new IllegalArgumentException("The name of the class to load should not be empty"); return new Type(name); } private final String name; private Type(String name) { this.name = name; } /** * Loads the class with the name specified in this type, using this class' ClassLoader. * @return the loaded class. * @throws ReflectionError wrapping any error that occurred during class loading. */ public Class load() { return newLoader(name, thisClassLoader()).load(); } /** * Loads the class with the name specified in this type, as the given type, using this class' ClassLoader. *

    * The following example shows how to use this method. Let's assume that we have the class Jedi that extends the * class Person: * *

       * Class<Person> type = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#loadAs(Class) loadAs}(Person.class);
       * 
    *

    * @param type the given type. * @param the generic type of the type. * @return the loaded class. * @throws NullPointerException if the given type is null. * @throws ReflectionError wrapping any error that occurred during class loading. */ public Class loadAs(Class type) { return newLoader(name, thisClassLoader()).loadAs(type); } private ClassLoader thisClassLoader() { return getClass().getClassLoader(); } /** * Specifies the {@link ClassLoader} to use to load the class. *

    * Example: * *

       * Class<?> type = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link TypeLoader#load() load}();
       * 
    *

    * @param classLoader the given ClassLoader. * @return an object responsible of loading a class with the given ClassLoader. * @throws NullPointerException if the given ClassLoader is null. */ public TypeLoader withClassLoader(ClassLoader classLoader) { return newLoader(name, classLoader); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/type/TypeLoader.java000066400000000000000000000070601211245343200301650ustar00rootroot00000000000000/* * Created on Jan 28, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.type; import org.fest.reflect.exception.ReflectionError; import static org.fest.util.Strings.quote; /** * Understands loading a class dynamically using a specific {@link ClassLoader}. * * @author Alex Ruiz * * @since 1.1 */ public final class TypeLoader { static TypeLoader newLoader(String name, ClassLoader classLoader) { if (classLoader == null) throw new NullPointerException("The given class loader should not be null"); return new TypeLoader(name, classLoader); } private final String name; private final ClassLoader classLoader; private TypeLoader(String name, ClassLoader classLoader) { this.name = name; this.classLoader = classLoader; } /** * Loads the class with the name specified in this type, using this class' ClassLoader. *

    * Example: * *

       * Class<?> type = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link TypeLoader#load() load}();
       * 
    *

    * @return the loaded class. * @throws ReflectionError wrapping any error that occurred during class loading. */ public Class load() { try { return loadType(); } catch (Exception e) { throw new ReflectionError(unableToLoadClassMessage(null), e); } } /** * Loads the class with the name specified in this type, as the given type, using this class' ClassLoader. *

    * The following example shows how to use this method. Let's assume that we have the class Jedi that extends the * class Person: * *

       * Class<Person> type = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link Type#withClassLoader(ClassLoader) withClassLoader}(myClassLoader).{@link TypeLoader#loadAs(Class) loadAs}(Person.class);
       * 
    *

    * @param type the given type. * @param the generic type of the type. * @return the loaded class. * @throws NullPointerException if the given type is null. * @throws ReflectionError wrapping any error that occurred during class loading. */ public Class loadAs(Class type) { if (type == null) throw new NullPointerException("The given type should not be null"); try { return loadType().asSubclass(type); } catch (Exception e) { throw new ReflectionError(unableToLoadClassMessage(type), e); } } private String unableToLoadClassMessage(Class asType) { StringBuilder msg = new StringBuilder(); msg.append("Unable to load class ").append(quote(name)); if (asType != null) msg.append(" as ").append(asType.getName()); msg.append(" using class loader ").append(classLoader); return msg.toString(); } private Class loadType() throws ClassNotFoundException { return classLoader.loadClass(name); } } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/type/package.html000066400000000000000000000027331211245343200275350ustar00rootroot00000000000000

    Provides a "fluent" API for loading classes dynamically.

    Note: Classes in this package are not intended to be used directly. To use them, you need to use the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

    Here are some examples:

       // import static {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.*;
    
       // Loads the class 'org.republic.Jedi"
       Class<?> jediType = {@link org.fest.reflect.core.Reflection#type(String) type}("org.republic.Jedi").{@link org.fest.reflect.type.Type#load() load}();
    

    fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/util/000077500000000000000000000000001211245343200252435ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/util/Accessibles.java000066400000000000000000000051651211245343200303350ustar00rootroot00000000000000/* * Created on Jan 1, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2009 the original author or authors. */ package org.fest.reflect.util; import java.lang.reflect.AccessibleObject; import java.security.AccessController; import java.security.PrivilegedAction; /** * Understands utility methods related to {@link AccessibleObject}s. * * @author Alex Ruiz */ public final class Accessibles { /** * Sets the accessible flag of the given {@link AccessibleObject} to the given boolean * value, ignoring any thrown exception. * @param o the given AccessibleObject. * @param accessible the value to set the accessible flag to. */ public static void setAccessibleIgnoringExceptions(AccessibleObject o, boolean accessible) { try { setAccessible(o, accessible); } catch (RuntimeException ignored) {} } /** * Sets the accessible flag of the given {@link AccessibleObject} to true. * @param o the given AccessibleObject. * @throws SecurityException if the request is denied. */ public static void makeAccessible(AccessibleObject o) { setAccessible(o, true); } /** * Sets the accessible flag of the given {@link AccessibleObject} to the given boolean * value. * @param o the given AccessibleObject. * @param accessible the value to set the accessible flag to. * @throws SecurityException if the request is denied. */ public static void setAccessible(AccessibleObject o, boolean accessible) { AccessController.doPrivileged(new SetAccessibleAction(o, accessible)); } private static class SetAccessibleAction implements PrivilegedAction { private final AccessibleObject o; private final boolean accessible; SetAccessibleAction(AccessibleObject o, boolean accessible) { this.o = o; this.accessible = accessible; } public Void run() { o.setAccessible(accessible); return null; } } private Accessibles() {} } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/util/Throwables.java000066400000000000000000000030701211245343200302200ustar00rootroot00000000000000/* * Created on Mar 19, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.util; import java.lang.reflect.InvocationTargetException; /** * Understands utility methods related to {@link Throwable}s. * * @author Alex Ruiz * @since 1.2 */ public final class Throwables { /** * Obtains the target of the given {@link Throwable}. If the Throwable is a * {@link InvocationTargetException}, this method will return the "target exception" (not the cause.) For other * Throwables, the same instance is returned unmodified. * @param t the given Throwable. * @return the target exception, if applicable. Otherwise, this method returns the same Throwable passed as * argument. */ public static Throwable targetOf(Throwable t) { if (t instanceof InvocationTargetException) return ((InvocationTargetException) t).getTargetException(); return t; } private Throwables() {} } fest-reflect-fest-reflect-1.4.1/src/main/java/org/fest/reflect/util/package.html000066400000000000000000000015471211245343200275330ustar00rootroot00000000000000

    Utility methods.

    fest-reflect-fest-reflect-1.4.1/src/main/javadoc/000077500000000000000000000000001211245343200216005ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/main/javadoc/overview.html000066400000000000000000000012001211245343200243250ustar00rootroot00000000000000

    This document is the API specification for the FEST Reflection Module.

    In order to use the fluent interface, you need to start with the class {@link org.fest.reflect.core.Reflection org.fest.reflect.core.Reflection}.

    fest-reflect-fest-reflect-1.4.1/src/site/000077500000000000000000000000001211245343200202115ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/site/changes.xml000066400000000000000000000133211211245343200223430ustar00rootroot00000000000000 Changelog Alex Ruiz Method invocation now rethrow the original exception thrown by the method. Constructor invocation now rethrow the original exception thrown by the constructor. Added static method 'property(String)' to class Reflection. It returns the starting point of the fluent interface for accessing properties using Bean Instrospection under the hood. Replaced constructor access in fluent interfaces with static factory methods, resulting in code duplication removal and improved encapsulation. FEST-Reflect now throws ReflectionError if a static inner class is not found. Added class org.fest.reflect.type.TypeRef based on Neal Gafter's TypeReference. Added support for TypeRef as field type in the fluent interface of the package org.fest.reflect.field. Added support for TypeRef as method return type in the fluent interface of the package org.fest.reflect.method. Added support for accessing static inner classes (code in package org.fest.reflect.innerclass.) Added support for loading class objects via the method 'type(String)' in org.fest.reflect.core.Reflection and the class(es) in the package org.fest.reflect.type. Renamed class Name to FieldName in package org.fest.reflect.field. Renamed class StaticName to StaticFieldName in package org.fest.reflect.field. Renamed class Type to FieldType in package org.fest.reflect.field. Renamed class StaticType to StaticFieldType in package org.fest.reflect.field. Renamed class Name to MethodName in package org.fest.reflect.method. Renamed class StaticName to StaticMethodName in package org.fest.reflect.method. Renamed class ParameterTypes to MethodParameterTypes in package org.fest.reflect.method. Renamed class StaticParameterTypes to StaticMethodParameterTypes in package org.fest.reflect.method. Renamed class ReturnType to MethodReturnType in package org.fest.reflect.method. Renamed class StaticReturnType to StaticMethodReturnType in package org.fest.reflect.method. All public methods throw NullPointerException if any of their arguments is null. Updated documentation. Added support for calling static fields and static methods. Fixed bug in method setAccessible(AccessibleObject, boolean) in org.fest.reflect.util.Accessibles where 'true' was used instead of the specified boolean value. Reflection.method now find methods of supertypes. Created class Accessibles to call method 'setAccessible' in an AccessibleObject inside a Privileged Block. Moved class Reflection from package org.fest.reflect to org.fest.reflect.core to remove cyclic dependencies. Moved class ReflectionError from package org.fest.reflect to org.fest.reflect.exception to remove cyclic dependencies. fest-reflect-fest-reflect-1.4.1/src/site/resources/000077500000000000000000000000001211245343200222235ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/site/resources/images/000077500000000000000000000000001211245343200234705ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/site/resources/images/fest-reflect.png000066400000000000000000000605501211245343200265670ustar00rootroot00000000000000‰PNG  IHDRˆ]¿ÇñgAMA± üatEXtSoftwarePaint.NET v3.08erœá`ûIDATx^íÝ ¼®å¼?þƒãœcúé8Óv2gØ•ÆU)DÚ¥4hØ4k°•ÒœPÒD¤Q¡’T*ŠJ) †ˆh$cfçøÞ÷¹®õ¿×³îµÖ³¦]{ïç~½>¯çyî麮ïüý^×}?ÿðƒm@P`@P`@P`@$þþ÷¿ÿà d`Ѥtjñ¥ÀÀ0,†aÀ§ŸÈÀ`P`¡R``x†g ‹Ž t‡x5àÕ@20[20pƒšø`N` È@§ Ä@0Æa —…ZcLc³íî;ó™ÔÀA,áÆa T3¯T‹Mb cÉì–A{‹)5£8èïÿo¶Hh¿è8¤…-ƒöS L¤ô‹é°ÃP`±£@[—»Á tÿP`à î7º/Ú÷âY÷Oo­.˜”ƒÈÉìÀ.¡œì¾GN†˜éóý¯Ï¥ïÈ'\уËþ]œ7™±;wÇ?ß&edb²Úù¡óP@–¾_έ'‡ãò2ÇÏnݯ^7ÑçÙSÁàª:&ë »ÙØÞ1Bc{¿÷£·ÏéЖ-›LÿÚ üĉh1‹ã«ÏWLÔ§öñƒ˜ µ&n òIo÷Þ{ïŠiñƒwµ—>?x^ðôà ÁREffKèã¡…5ô„ƒøÎw¾sT°çäó?ƒ' ]„—¡Þ¦"ÄýhÓdûQJŠ?cÛÑG½yî»L°tQàÇæóQ…"¿ÍÖøÇDxFúðÔàñÁ¿8õ6Æ]ßÞ%Üi[v:Q)£}¼–íg4–ÂÜŸídœJ€c:‡?üá?úÝï~÷ãûî»ï'¿þõ¯ú«_ýêÞ_þò—÷¶ù:þüÃ2†í‚ ƒU:÷ïÙš’ƒøñü½\ºM°EðŠà%=¦¿ƒmšàrNæ˜æ-û¾üá .½ôÒSÓãyÁzÁêº<Áå(¡^4+Äú1¡sHVrG÷Îßÿþ÷wÅÐÞý›ßüæ'Qà{¢À÷täÝwß}ïŒwƒ`í`…ใÌQ0Æ^Øâ§?ýéÍ…?ëçs­@™‚›Sú%ãÞ¦’A1GKq”]†ú–þEìıøþ\vÐAí›á¼)|(818åå/ùùo{ÛÛ®<þøã¿¾ÒJ+}&ûŽœÏ±®0æ²÷áù­/}éKëqÄ[.X°`Ï­¶Úêðyóæ}býõ×?}¿ýö»¨—I·ÜrËݹô˜àð`÷€óyq ˆlÓ¤@GPP„À¹ÓlmäåÓv¢–½÷Þ{÷wÞù[o½õ{7ß|ó£&‹'<á ïL·ö v ^p+Œ£tõ_ÚÝîR””fNË[Þ²ÇöÛo¿ÿë_ÿú÷O¶ΟL?Æ3h¡Éµ_ÿú×Ýu×]eŒ*EÜ1Ø#x{°_pðFmtÒ!‡òùlWÿà?¸óç?ÿù/6ÝtÓcslÏ`Û¢høEÁœ€³|HÚn&é•£>÷¹Ï­wÜqÇmzÀlß5þ(ùi]V×þ~i´îºë¾·ðç-ùœp`úõÂà) gx»ŸÄð0ã„+N«‰Š‡M–ÔÅÇÈÍyŸèý à¤àœàÒà«ÁuòÏÁ Á׃kƒ«ƒÓÎd“ÂÇ:–}‚’uƒÝ‚ã‚K‚«V_}õ›zûqà 7üƱrŽs]ãZ÷lÓ¤@¯ƒHÉ÷¹¥¹JÙ¼’ž@ºÓlmäåÓv¢âÜòÁÛ‚÷™\ï>î÷ê@='xx»Û]â’K.ùdÎÙ)`| é¬õ#í?±Ã«ÿý¿ÿû¿£}`Úa¿* ¸ŒêèJ¿>œèï§ZE\Ž‹þ8L Ì‹ØEdm£Ça<;X5بkü¯zÕ«Îê2,öOFú¾è¬=íj_?†·ûÛAï]wÝeeÍœ@üŒ(S¶û»(|ï’ù”v¾’¾oœp·"ÌïœgÀxƒï„ýç?íÈ í^™OÁŠLÄõ7®ºêª·ôÊÓÕW_ý—ã$~|©Üw³|NjõÛ¢À‡û£½¶FU"ý 6ðè¥=ä$ft›¶ƒP*IDÅ"_髈æœàÌàŒ€!<¥O0@¢šQêJ9¡ƒHþ¹œÇ8Ÿ|>øB`Ÿ>‰–>ÑgôuÜ~„hꣶ‹.ºh—\k’ãwQh–‚}¼ôãô|Vè'á³~¯NÃu2+™g©®+Zo—Ûf¥8äuÈí :¡S^ñŠW|¡«¯k¯½ö—sÞÁËç¹ùdT?]ú¤¿§ôÀ}Ý_;ÚÓ®ögÅAdNè†SO=õÒ“N:髽8óÌ3¯WÚè[ÝwÙe—á¹ Ã|GÑ”QÅ­+ IÙè=ËÑÁåÁ­ÁùÙÃ9ÁÇÁY‚ôok9H†+øèÍ D¨²xó äïOU®ê¥ù×¾öµ?åØ}ÁïJ_z®c´Û4)ÐË{óL¹¥Š]\ÐE¼bft›¶ƒÈ$ØÏÒ££Ƙ`ŠN¬zI0:œÄ)}bÊâŒ3θ(m~‘TM¥Aácxg¤]Ê:\œû›?Ù4PJR–ò¿h8Mø~w«­¶Ú·Òoõóš|Wš@?ýìr¨ ÕAœrÊ)øÇÙ×xÔgêâßL‰ã¾.Gñ³ŸýLD+Â6qú‚Àdì"ç$26“Ó#6sYË»r[Àh|; ‡ô@ %``È@fΰ˜'˜p²Ý§uÐ¥dZÀã^ ¶ÜrË#zû’r*ÇðÓ`à B„™ÞzíM õÁ¸ù$Y^>sÚ^p2á½ÓÑQÏA¨›çBåÊ[£†Gúk s¿åž)—˜Š1á¤ÐwÒl5Øÿ ì?e¦úÑå ¾üå/s<ù[QÇ`ü"u}M1²"9ç¸Î§ß䇇ýûµÜ6V1¥ÓÊ+¯Ì¨(6ŸJœƒ#ëÒ‡^¾-ÔÓ1ÇÃàéçïƒ_‚†ðöà‡-ÜžLãw]Nbß}÷Åÿ½ƒy¹œÇí,,?Ø[—ƒ¸óÎ;Õ¡eh„‡äsÀ£óx2ð¹Áó Œ_9Éê%òÄiÊÐÿ-h—.DɉC5m®I„ºZ&÷í¥óM7Ýô«»#8ˆY¥^{“Àç—i†MùQ`nˆýتðxF{0í ¢ÇAÜœÞX‘_­qšï{õ‰)OR·„:«:¬z,cÇAI¯ÕΧÝ.e¥0{챇¹†7 ½\Å8É`\†-”ãœk¬o Ôó}ú½ ôñå^óó9/ÅQrömE~T~K+)°r²œkÜ¿«‰è.ÃY2±õÉ9ph§œ“~öÒË}Ý¡LRgÉ/§Å!ü1PÊüné'§+³Yêù~ô£/¿ãŽ;þÔ;Ö‹/¾˜ñâ¬9[¥:%±ÿ,2[W`vë­·2d ]d²w™çÀ1üGÐ;÷òàì“AY ÷ÈçØçX{ó›¬9¦ü伇gR|•^ûÛßæ¸éÜÀAÌ‚Tõ:ˆ¬Z, Èï+Ÿì› ‘˜Ñm&„²’Õ_ Î ¤>Œ²^Ÿõ0†“^æÚrwSpy ”û2t[öÙ}³c9ˆÓN;MuXi“W—A‰è””0Ðäû‚Mé ²Ç:ÁË椧 ˜öe"Œ°ã"7`N ŽÞžlå=¶SGV.X«Üß}æeeÓž]bÍ5×äH¿0º>9ÓScP‚ÐÏæ-è·ûkgÖ—¹¶„ PýT“…½/ [°`®ç}™,ýaïX˪ŒVÉŒ žôFÌÙ5ö–ûZ9æÕ(u=º¥Ö–Õʪ­0R³Ÿ•­ËA”¥¥œÚÈ&”x÷ LZr³RJë’ÿ›o¾ù޴ǙϪƒ(m£·ååõ9˜úÚ|]h[é y¨¯ÓiznáYýv¦Ük¼×xö…ƒ°šì%/yÉï|Z~¼Ã;ìÿ¡}èuãÝ«ßþ´Ï›IqEnÌ9PâSJ»]ÀÈÕw¢OÑ”öÉRÀ£FpÄ ”"#lAËA0Ì¢a“ÔJ9Ê › íDí×ãcöƒ!èõè:òÍo~S-¿ÎpR—²(ÎAÙIwÕ`nàþϤ÷ê¿>ýV.Ò‡eå€ç•ý²ôõµ#=¥Ñ zñョ–ó]׌¥Í(±Î:ëÈpð«:uYŽÌs˜,WïÑú¬ýÑŽö´«ý%›¶Pu}Ïù£¶.#Ør¿ÈxÊ9pöV‰§Ê™nzî¹çŽzýD"Þ¿åF.Ôm]«´¢ßnÅø÷óÜ %vžûÏèÖE›Là++q|ððÄ@ö`R^´?+Ûýá Êøûyz|VŸ…I?þú®ªQ:Õ±£öç5c1£‹žýÜx ç(ANz›IA9 †ù¨@ÉD4óÌàŸû„¨‡±Ýq ŒáƒzG5ƒ¸,ç_œpRR/5Wå™éG—ƒÀ°C=Ôœ‡¶^9¥U.2qÍàŠì”7ôÃøêØ|úmü”Û9œ#øÎ1p”hÓ¦‡ïhäZ4sÜ=†Çy÷Ýw¯Ô%L¯|å+Eœh% õ©¯ÊJ2}­ýì¥Ù„<š¡„¢¬$s`€eTø "wÅ3â¤íëøÃÿÎ1‘­ˆrãrœllÌ-÷‘1ôãF‘7Ë¿Í:½ü¯Éñú2jî/eNϘ8<<6˜p~#ª)5:ÆE ÓA¤-¯°éÇ1ŒâAVú(õV=› Š,LéÝW:–åïøCéèˆRÞÂrÿó?ÿ£ŒÜ” %Cz<ª?½„šiÁI¨ ‹DÕÖ•ODÈ3ºõá <%å‡-Q•hwF¶´ß¹Ì•0ä]7w¦‘Zfë¥ÆôÖzg¤OcÝd,,ÏA˜#‘íø4!­7/}P®)m³à ÌC+%%YÇл=$O«ïßk)®»î:Ü'#x9 P*SfêÜ Í¦d˜jûüãïüä'?)³‘ùÉV&UÒjw,÷å ò¼ÍÏsŽù#ã3ç§”úú@v:kÛÂri§óÁÀ®`g¬}Yée’ý ôÎÇôE£Ü[iZ²ð‹_üB¦W˲úcQ@ÓŸ…å <МöV T1T'–TÆÍ¤¢/1yRˆöÈÿýßÿSh²ìï·o¼ñå¹ê=2›ˆuÒuï)tmÔ%Kƒè|Ðg?ûY“¸÷p„²’ÞXôêäm–2éšk®9!OÈ¿-ï4z÷ 'œpNV¯Ý`UI—‘²õùϾ+£mEaTF<Ÿ»D²%e7J?«uÿÞ¾- 1–sð j<+ Ž©on°¼ýúë¯ÿnÞRÛɃÛo¿]ô.@d9оçfÒq_¥Ãè¦Ý›½‹Êª²´u[¶Û-ÜiËCOXq÷¦@öKhYï#j0žŸÀÂsž/ótÉVÚùï,TøŸiû©ü ê5]ŸioA°[‘ÿ¡|*sVcn1‘vŽqüÏþ󼉢™k¯½öÖL«{ ó ¢†AÑAÓ.#Øšƒ˜0ƒÈõJB£ û›ßüfÑ›U6FÚ×=¢´×žxâ‰2â×Vr½7°\Ù¼•_}öÙ?î’‡”‚nÊñ ƒ—æ’FÌ#åš~ÿaÔíS>û+#ñ£ýè1¿òޝÈåíe ]/>TîœÖ6Û"÷WçµÅ`^´ÁÌKçU,ø°$þäàÌà‚§?ýé—[nÛumyˆÖ†YöÉQ»å>2‡Î-}¹ñŸøÄQ¹gC ”÷ôÅj¹³ƒÏçAÔËsÎ÷ã<~[Ê'e¿Š‚kdÁʤmãÌq™ƒ|y@ÖȘ*È©?ùÉO~ÓîHÑ_²ŸL×O 8TdÈÍ5ã@?eâ–ÅÊ(8ª1·ÅÆA𞉪~~ã7þ¬¬ˆÝâÞ‚¡ùË_®Î`{ÿ¸§ý[ ~2ÛCÂøÝ'rŽ‹$Ó·ã>øà¹iÀÒÔ©M÷ÓÙ.…Ö§Å­ÄTx;‚ÞoY/®^?a¤‹GEŒÞ«Ui~> L”›_™~=¸¡àú}öÙç®.yØn»í¬ ¢æÂ”†Óú®~÷#SSMù÷¢ì >þñߺâŠ+Þ RöM6Ùäø½öÚëÍyçÕº—À˜KS—¦¤ÇöWAo™Êвá-÷•=d‚ûÃ9Á’ûX¾}SÀ9ˆ#¥…ƒÑ©`ïzÞóžwü%Îéð@ZûØÀ$å”VJõ+gíóÎ?ÿ|s›ÀJµµƒ¹²—Òg_Û,;ˆQ´xÿûß¿g:¦¬' ÃËjh9+9^ýñá€ý÷ßÿÂ^ú”Å u¡ƒí¹Ý±åºÎW‚:ü¶ˆCù†­àî8Ùä9Œ‚¬X0 _>e ' >úÛgÀ ϶ƒPbb¬‡Ùæ;˵Çxî¡=ž”˜þœcœ‚“Ï›6´7”¼9Ù”‰ózß#¶ûÝA”^4cm½ÎZõaÅ‘Z-¯:jõÇl(UVP|ÌY=P/¶’Ãôi© 7%ùë#&»f›LH~à¼óÎûA¯ÇO™“e}=˜eÌu)ÜŒe‹²ƒ˜ŠtM"HŠÈXøüN`B—a‘ZïˆâMXo¹lÄü…7fæÍ¥;ç“ÚÊß Ìgp žÌ Ô•@Dd››”ìí{^šhBYø€€’Ú?<ç5¯nëÿ<åÅ„½÷󂼿øÅX~ùåÿʦ¯ßõð£—鹦 }ìcO›Œ§¦LÂH‘sP_Ûl9ˆB‡Ã,+o”cXÎA å¦@ôþÁ€ó0'¡¦þø`…ÚVÑç“»&s³ŸŽ×¥Îk廀p„})ALj~$ëÇ{F•s5Üà'yøb€®²ó odúå“C6דIße½ÆY?¦Ï Ì Ì+×nÓûß1™sRV’1ü±|rhäþÚœ9Õ¾…ìΘÛýî ñ_–®¬˜¼Ñq‘¼ÎšPêru"‘ão29üŸVz$­¾Çk (m^ýý±C&£”€Á¯ L,[ý` '1\7nQSßLzI A9<Åy‡~øm]¯~ËèE€Mq”$Ç#¢¥Lk[’„rDÞúJQ攤Ú™B3ì"øÍÑãpÔÜE£¬LâPö >ÔÚòåå¾îÿŠà\6 ›¤àÏJÉeÔpxàJ\Œ‹2‰Ì‘¬·”‰‘]ŠBeM© K§ïè•›d¬ žHò‚ßwŒ†6&*3ˆ¤•ÚÞp–úß×6‹bÔRÞŒñÜtŠƒVV26Ξ³VC‰]:ˆþÆAWŸ'àë¥Yþ,I©Oöçú­¶†® o½‚{d¹²LEYFæ€Î5j'ú'ˤÿÕ~±úå“~q°F9‡€ Úü§ëlŒqp\Ž»öù‚•öX¬XÊ~å$ój>9=Îa^½f‚ÏøÖ 4§woÓv–tåiÝ ñ»ßýîŸ÷$-¼õƒüàMQÖ«N?ýô‹ÏgËKÖNO×ÌÚc¸ú (¡)1f` at9ˆÖ“Ô˜hRˆRQ›ô”PPЉphΑÒVO[—ÈuEYæ!¤©sçaW«l&Ò¼m4Ñá/úÉ*²4MDÂÙ<=P#5vuÒ)gK‚ƒøþ÷¿AäN‰ÏL¾}4`TDœwjÖð®lÏ$åpä2N™7¥*1]'÷AŠ)9ƒÎÉööO Vé5NYû§œtgp~pP ‹Ôëç仈^T\å¿ñ°Ã5¯qÕUW©C+1p ŽÁ#Ú\7.ʱ£Ѭhõà F•—²œøCéãlL·²¼ˆ‰€ëФ¶~øþ°Õkzy'}_Ž) ±9o ðQ@Öl]º’&w/³Ì2hEôsQp‡æ ” ´ |oŃáH.UÎqùㆃ”Ú‡®Ï^§µ¨¾‹IÔ‚øjs&exz)>†2˜á=9Óæ¯8 ™Ä(Ã<ƒ¸.׈M1¸ú…¹úÂÓN„Sr޾p›„HÚ7¢$Ñb¤H³õUŸç"ÄÃFéœà’§=íi×p¢9Šd”€2 î­ôÔkˆZ]ûë¢ì ,x(K9ÿ¦îšìï÷]˜µçùo†ä¨à3ÁWå„[²èØÞ(ïYÁˆl°«¬ Iò‹wœÃ­Rƒ < ¬ˆ'[Ö³ïÛÛOYmNþY€¿2™ª¶–.•¥ å+zÃ!*ëp8²÷”Iü4¸9ËšëÆ2ùžÌ %¦QK”ó7§Oß8zúŒ—gÚÈÞZº×¹åÉá+{i–‰j¥Fžƒ|w R k2õ®@¡¼5WI‘-á„Ù7×Ë8zJGrmt¸]£_£ÞÅ”‹ØµûÊ'~*+É8ft›‘ "="Œ:Œx¢$ÖoJ%’Fà‰ …Y‰ò6 ¤dR´Q†ùæ c!á$D6j¢Û]æ"ƒq¬ËS~ºÝÚõ±ÊMɺÐÓ=8M¤$›5“}ãn‹²ƒh=ÁÞõ”§<åÛ»í¶ÛÍž"î¢]މ4e¢}Ÿj³äŽs±3È¢åζKž¥ýŠ3ç 8'ÏÉðîU÷—åAÉñVçèbù[NJVóÉ€Tã,Ý'ïöm¨g/€ÌAœ×;Þ2éz_ŽsØe9cøšëÆ’Èk²Ê@öÉæ¼Î({&V1u•vBóûÐÞ²NåÚ,I9þ×?UrñêˆrÍX<%"ª‚RÙÐѹAã¤sÁ¨7$„odê¼àÇáZ¶ÊŽRç0i½Ô^¿ÛÀAüŸ/ªŸ«“ ,sŠÐ™apxûG2Š3ƒ †††®çn~™sL¦r” Æ2rÛ£&+Œ‹‰ƒPJ¡Ø¢?AÈ7»Ö»3æYE$ÚT‡¿ ©££ÌsP¶uv9ˆ±œ÷T÷—ÿLA˜,˜ßPR2oadèŸìD_eÊ?«%ûøHo»Åá¸穜tFp` i®Ê¡²be2X?ÑoÓÉ.yš-1UZuÝ{ßû^ÁëoågÙ Ù0Ó”±»ä HÊø€ü)1™¡ÏªæŸÆÌb‚ÍÀ6p3ë xø…5Ñf?'AXD„Ê"Š(¦´£`¢ô„@ô\õu ô~ûí'Ûx[`%g#}t_呾'¯!Jæ4)¸RŠyÑ×*9å®Î•A ïÛƒõƒçœw§2/ !Hû2ˆŸJžæº6 ”mx*ÕG5kQ}ƒ®wL}ãß@¦æ”ÔdªósXÃ׎ñ35s “*].Êâ=ïy,€C•qq¨{tKöÖé Ž?þx²Ä¡ ³²eËzi¾ Øf}[œ„ô”—¾œð¸A9fç@Ôý²`¹`N`xÄ6A‰é«9™áõÕcÕr)ã›áAmXmr€—ö‹ÞGÔ­{ûÔúMá(8¡S'u½Tþåel&•<ô郛nºéÅ]Â39.«bä8‰¡r/¥¬Z·§ÿwh1q”“Ó¯<5‰ûáÍ6ÛlÔzw´ÌÃmÎ=)0$’æXÇŒ’»äÉ|‡ÒFVÀ5óæCLzÇe‡ý@IJ©ÊµyvCú«à¾@]½Ö°•%ÇÝÒ¿Q“èå]L Ú\¼?ˆ<{¢ûMçøÂtʰ^%RKLY½ó[«=„Ûý“ÕL?÷|~rÈ!2.Do'sëtùWCår™Ãov­]ïï;óš&Í‹9+†Lä˜:ƒÐ^_ý™·7±¸S ’êÚW[±/pK}åœk%…hP¤æZ÷Q¼8X;0ÑÉ-ì}†‘+%tä$d§²ƒš1§ÙW±˜8†OÏ B2ÅÑï®FÜë`½,1ÇÌã /z‹Ò9íέKžvß}wQ#£þûÀ‚‡kåΉ‘è‚A ÇÆi1æ“6èK¢ƒ YØ¡ð§ÿMRË””hÍôCçÙ¸²#‡jRß'¾ì°9æø8ˆQK–§à-±Y¸`‹Ò¯R =ŸõmqÉ ®¥¬ úr`!M´™ ‰OÆÓŠ€gj{¼:CØW͸µÌUû<}5&J;ê…êøOî¢~ŽIIB¹HæÀ9L*/RC€\çzcq_^yÕÒ¯-»¬ÊsŒœlˆQ:6`£ÖÒûŠ^AA/ Ì)È2‡æ*–·ve`Y"É 8ßD¤ Ž ¢. 8®Ý‚uÅãnKˆƒõÄ.»ì±¢?ÇJ”¯Í? úåA/ýÙ(ÙýÆÀ$õc1 tõ.(e®â$b*‚êA¹\Ç3d€øGÊ:æê$ÜD·ïûø"ê êøÚYÅ£½áµ¼¢y„ËÆ"VBVV®y)1c××Ùbê šˆ¯lÿ”§åwëÊ"vÜqG+š>V†ŽeT1Žaà dx!='°À ßòF×y)È•eͲÊq·%ÄAŒ*ïä¿<8fÂľyEÆþÓÁ§ÉYÀUdJÉSÂkOFmÛl³ fà ¦"¨1ÕÆ=þàʸ[—sšB;—¤´dI«ÚªI´ÓŽÈ$¬©÷<ÄF•a–ÍN¸-A-Ñûjd„.YÄå9nÁÀsƒQF>K_è_ÿº˜ãa·+®¸âº¼p‘“±­Ó@zËF Ä”2ÍÊÜ…å Š!š(ÈU‚ñžªC=ôÞw½ë]ÎòàÛb¸®¸ð ÏÈ[vlLC kNˆ“ßk,}ÒNÞŒ|IÚRf’Aw-80Ÿ´|‹¾6<è§íÖ9õêø±úáPßýîw¯Ïzß“2äšy o…Ò¦v ÛÁ =žÖVähT—<Ä™w·}kë­·~ßFm´>ÐP«?ú"3›RrÝÀATªçiKÏnxVBd UçgˆáÁ³á ”Fò܃(Àºxю󜬤ÇQg:¤Øžé+Š]ÂÄ?ƈؙ֥‹¸34;-Ø3*üíÍ">ì1–a¨û9‘®Æu¼´¯ëòEÅAÌæ¿ÛM| úð8ã³&â@à¯ýëX/Mì½|²ÂÒú'å?A¾5Q?ú<Î8sft¶¾³ âðÆm.NíîÈåm‘ËQoÆ‚“lØ1p-’'"¥3b£Ô"Í9¥ˆÅCKdЧ\Œš7ƒú/ƒüæÖ¹·‰/ÎÁyõV+—Ì=(9)oX‰c‚ŽëK¸–0A¦ÇË"”ì,3刽’¢×ÉZ‚ü¸dy¥ÆŒ097eæ¾²ŽöC˜"½QÏø@ïV"ÒÝ™WmÌFðS;¨Ûó(J{/åQ‹=º@eHŸG}æLÑ?s žay\Ñ›üéÃxÏY]¶lúñ•éöÃSä^Ïæ&Éxt¸¯*@•‡ÈäéSí‹`&÷1&¶ -d`Úÿ—.™«û&ë Ô®P«MZuc¢µ[ò²¹ïäf û9ˆ&eò?Òþ9Ê¿Äe»+Jóó©þ£œ{䟣L[BÇXoPìå s v³â„ÑMtñÖàÓèàA·ü±ÈO¼Šx,Þwß}÷@¡Ùe'œp‚ŒAª¼cð–@]ÓJ™3Ëé¬`bÐ>(˜³<Ò$+æö5QšþXÛ}E”äÊD×'…¿9iém/}éKÕäM¾ÊP|ÊZ”Oæ„xÂÕ5hѵµ…ªëû׌zеõºïÎW#ŒÑü?æ]=£þÑ-ïóù[^îÁ+K%Ñ{õO{éÈp?w5ÖØîÒK/½Éß;NU)ëuï|ç;wÎ=½QÀƒq<(j_õâÅÁAäou?žñz†Ç³Q–ø>«Ð KΖʱe÷ÙgŸÃòÀcç„ñdxRþºíñÀ”àoé`¼y<ýòã:ûî»ïÉ™œRÀÀ6ä9KÖ7 è»1»R߈0†wî~Üý×ÕûwªýТÐ@»æNÀs«éÆËœ”ƒhuÙMWÔs=­¼PD«¼ðPÀ¨{2ÒZuÏü0øv`yè¼G—sœ7ŒI9G¤I MþŒX/ßž¾|A9Ž~:ðÕ¯~õgò/rgl°Á§n¸á†'¿öµ¯=1øè ^ðKôÜ8Q•ýüAÃsÂÄ`s2 [yÐ뵚ZÑ—hw2gøç‡ð@rMð!ÚÊ‚ƒogÙêtÐ7ÒGÎa2â2©üÌ8ìRªøÞ-·Ür· !ÏDü倸MsììÊ"mÆ›!ß.“Ó§ÄÀÿÐ?•ÿ†øËX Y_ §ÝÄ/wÜq'½ò•¯4ŸdîèÀ€c²È`€ê7 E›L–ÞQèò»|^ÔùcšÒ–q5WJžW‡~×û;`c±ì?ڈýÓßùzyÞªû;K‚¯¼òÊÿA'+lügÚ×kòVÔóÒ©ý èp]ËÆ«q^;Ç÷Xa…ÎÍõ÷âaýŽ.ÐÚV (”ì¡/Ã’óÚ¥{^@0*¥¬/²Ÿ~Ûï¸ójÑê¨2„H“R>˜´ƒÈ5ÖµsèëV~Üxe·Ñ,‡Ž¯èÙël•æ¢M+ÛNÈ‘ZöɾîZuÕUoYsÍ5¯^gu.Ž8gå•WÆK ‚Ów¶Èi5 CõºàEÁ¸é}Ž÷n]´™1ÑjLàÅ€obô/Ú0zÞü6økð‹€þÑ=Hïu'gß¾Û!“èŠ`ñCùC¦Eé–EîyÇ“žô¤» ¾\µîºë~1<ø\œ¹{Wú›ï М®Ñ1}9*Ø-IÓéñ6r$Xqèï!Á9ÀŘ’ÿùñ*«¬rëܹs¦t¸ÚmÒ¶À~¶QÙX¬RT¡PvšÌ&xaó†c0Þ‚»C“Ÿå?·ïŽ\~7¿™èuR@Á¹ö¡ƒ2+ÛÆvýçx˜ªƒàYy2ŠÌ#œR€AŒ%…ç¥'Cœ®s11⌃ŠA_(´ú=ƒ+³`ˆûqÎéÇA0,h0–ƒÐm¶Ái@Ýç;´êT–ö9Ù…Žœ £Í@¨›÷U»î!§B ½ùLX9,Ÿ~Ûï¸ó¦â„š&§RbjõÕ•ÒR4d”ÁwûsÎD£<ÈÈ1Œg#p ÆËøÌé+úºžC–A’ñ£‚s‚«JȪëÞ0\ö NàŠò©ö|mðõÀó,ÚedÌ%ÉJ§â zióÓ܇ƒ§ƒtN}{º£Q ³àFßoé:rºhzo𫀓à î ~ Qïuhs| C@ª‡wmŒ¡cé¼@ÖkŽñÓ2¡}<øv€Æ•Úèåá‡Í@_?Ø01ú 8[¶å¦Àn/ý"§~ù® ï“L«(yM%x~T®{NÀöºû±wÚ¸#à¸ÐÅo4!ƒp]é¯>sƱQ@ÆÇܦê DÒ‘áݾ9Á%ž0œ"ì±`¼~õ{Œ‘V6Y'¶aü‘ÏÍ TcŒ ý:‡~'‰«žò3¶”J´;žƒpÌyÕH‹:¥¢ÒÀíQ†(—@0Šèþ~‰Ósžhˆ@®Xî»S>•=Dˆ>ýÖžãÎsþ”¶i:<}i0¿ôM™ ôÓ>Çœ3ѦÿO ÈÞ\D½ÀaˆÀ(霠Ë2P ðx(Ø: T¢Rr%+¥˜Uù †KDGƒ¯–s.îiWôJ1'ë„»hÃ9ˆ9³©\6bs÷rO÷ÖÆå3„Éð}þ=ˆqŒd”ˆŒÝ]9~´f Ñ|·Ãp\–|aÀAW9¢·¢ñ~6N‚þÍ ^'ãìžœ–v8 }¨ð[À “"w‚?Ù›ÉáÛd·ê8k€NŽÙ‚ÐTÕþ{ú°1[5ø¬ýÍø&}'D5'à (Pb•á¦T élmw©Ò–¡^¬ MŒ%#m\ÆgœÆÛ.»`3Fc­ísT®ç\8,ÄsžÈHùnŸcŒó¥œ¢ã§ÒYÙÚi‡‘šîÆnQ¨ùÙÁÜ€ðé·ýŽ;o²Æk¸ÓtÆ+¨Ð†]Áwûë7òF7FÐtN'ù¬÷£ ý”ÓÜËyÎg\8 üB?<çp8éÚG8Ñ"EP ­ûL…¾]´a0}"£Ó1:¹¼ÙÜýÜÓ½µA>fSå¥~¡§øIWè<]å4DæèïÓo:õ¢@ àÜpMW¯zû1'÷Ægüf*üÖ?òVu‹üâÿLè4š 2E¶È4Ç%Ð3ö ô±=«²_e±_]ÒVß"’ I h¢2¢ïOòDÀ 6µÍ˜SFÄš*|c1.ã3NãíUjLÖ‡J‹ÚÂK %†`!eP£ì£, ÁÕãàMÕ€äÒ1·jàÜ_;Œ¦ˆ¬Âïvû3%ÀãõiQ?F(þ“ur¾ÛçØTÁ¢N—…Õÿªô… ÛèïÓoûéçÂå* Ú¬¸?øß¦ÉýÙ…%‹l;Eh(AÁ,FƒàúôÛ~Ç·0„x‘%æ ã (0 À€ (0 À€ (0 À€ (0 @(àýEÁl®hZbè\h‰žæ1ÛbFú²˜ð–íÃ×Åd8ã#õh½7~X¸‹À{}ŠµËƒmŠý¼ß¾ý*ß+¦x«i_–~x?ÐD2°X𻌵þ)TýÄ ËglËýzÿPj± ßL¨yë=g¦Úžî}J¿ØÀÅßI´kÀcmÄèq&cÇ„|¨J4ቋ٠ŒQ!4åûòy«® ¢N„›ìncV'¾Ó~?ÿðýE™ En«CöYÿ=°í¤gĈçÞõï6} À–Ï ×YÎNœí' ¯ñuVyû@åYOp4ží©ÇšüMd—zÄ´là•?ÃýªƒÐ^áß”òöÍó é•¿÷½ï­òo|cõ¼ÝÑC–M‚¥ŸÊWÉÛ-­c·”ê’ÀúiiÚ„gôÐÿ@aFÀÔ彖ࢩe²–ç¢{]o?+C¨"ï™?<†lÅ»ï¾{%<Λ#WÍÛ<×Èkš‡ G<ü®KÐK@[NðÄBÄáåÝ_ùÊW–ÍëÛì’c–V[.Ü»T¸ïñãWåÚê6Keþæíª×äÏq~XÚÁo:Õ—¾Ì óï§›‡½|Þøûâ*s¡ËU”"¯Õ>ºÊ\ûsaÉßDv)Çk‰‰îÖ帽6^,ú««ƒˆqPâ¨ixöÀºþöÃCªªÌÉwÏxð¦>¤ä¹… Ê5áK-FT%¢H½˜•‡?î'½hš­ÆŠr#ë¹ ôôV}€ÉMž¿`¬8á™xhªsص?1^ïÊ õ¡*m냇%õÿÁƒCöÉxêC]Œ\ûÉôû“¼£Ú.ƈía´ÛÉ¡­1Ô’ŒÍµ2f²ø‚? @_N¢å ú  úÏüGòuþu°´éÙšzºWe±“ùq¢>,÷ïùO˜k1éæ›o>ºÈY•¹öç¬Ëß$ìÇÖµm_ý>•§ëPzÓt¦å ®,õ°—Áæž"]+xY0¬w—¿šßzë­ûæ7ê6Ûl3'Ì=Ï»çÏ9çO=R¨a‘6š?º)‘3ï[7é½?ÀÉßë}b4¿k—ä“c¢Š]º(—ýÍ;ïݯ}¼ì?»ŒO}½–Fd+Ùï?oÝcøx¹Ÿ§¤Gm9¦\PkËíkÜcÂIHã¨ÂgÜqÊWúÃ&–”?rGcOjzbsÙDïGùËAѦÑrn.鬓·î‹®úXÿ?¹¯ÿP.çÿݼ§m4ÃÈ@2”ž ÷ùÚl²>)¾LþËw?ÿùþýÀ¿\:j»“_…JjíþÕRÏá•à9þšrÎx÷©ÿÝÉ«y°À&"—š,­ŽÓÔžžöÔ¾1’{| sòV»Íž¿$UŽjÉcÓ¹¦ùs§ ðן<ÕÿÙö þ+™.%b¾ íü[þ£yyíäaöë¾"w´-ÇyoÑTýè•ÕÎåü×›Þ±ôüæÙ'¢º%kýP‘·uóÙ öè%Ûn»íùφOû»Ø–ü¡ÏXºÛ¥ëèBŸ‡ŠlNÊ.%Ó¦#lLð±ù±½« Ìÿg¼J9±èD•ñ1eµ%ó•W®ÕŸj3ÆÔ… è;½Ãé@óï_ qî$Êñ˜yÛ0x•0`+äO66u~þ¼â½ùÝ8ˆàq!ÈëíG B´¶ƒ¨5îÆÀ•W#ñw©%CQ–ó ´þ“¸³6\ŒˆfGL•ý]ÿð¤dKZvÜDe{bq„1&D*×8݆ÿH½·]\i1»:Æ«8‡ŒùºüI<‹”VÉŸƒÜ¤¡8ÛbD>º|¼õß´µD2ÜDåaéKÛ“°N¤U:¦Ìr`n:'!è cé=9ó¯Y3hć?üáM4DA9õŒc¿ú×Ϫ˜ÃÂŽ®-ÞPæF©ºèXd¨Q¤±Ž·÷ã¾2ðïyÏ{”íÈ—§â9d©W:ïê‡DÊg¸– >Wh<,7=íTƒÜ ¹‡Ÿ ¬ücaŒÿŽùzßÀiäûE¹Lü‰è™ë¾ÚsßJ†·=Ç‘®ýU¿ªlWYu®þrEfToúàÏ(‘²ö‡s}بëvØaÛTGËfÄÙšSÆe|£©Ö±J`oc_ФEƒ í’ÒX.v h)¼=®È[[ ›þÏõð°ÎI¶õ¢ò¯ÎgÍÈüXüÕ¹ÆAæüMçï{ßû¶Î¿umÿ¶·½m×·¼å-{n²É&oÉ^På]C½‚)Cî'Õ¿‡¤Tù½T𰹓Ý?‚r~+“ÔW<ŒS*ÿ1«œ¡|UÁ¨­¿mû\ážõµÿ"B+Ç1JªÚ¤èu¿¨Ö\JÙ__KѼJÄŸ¤»6QÀù-læSÎ:ë¬gˆêEî‡~8CÉ ü[ß¹ÎÏ¥Ð=ëëIDÞÊŒO­a×¾Ž˜1ßã^©}3HŒ”èU¤´QþÍ«i'˜!plŽ{î´ÓNO]:–žzSíW>-ò/ùý|÷B±J í××pˆrÐOô\_9Ò¼G¦(ÅßÕá?úѾöÝï~÷ü8¬÷Þ{ïݳ핶÷Ý|óÍE0ÆÞ8ˆüÉË‹/¸à/3^iµ{>â­o}ëôçŠ+®xmö¡KSkÇŽ.óhÝ~ÅË£ó/c¢±JÃ'ÈHÝ#ùêÒçáL Â˽8¡zŸ®ò$YkÊBuŒøžVûhæÐÈ4¹©NAâ ‡3ˆüË×ÎEvø©O}Ь×'çCÿqÇÒ—O^Tú>¢ŒóÖì÷š2MñwÃüMìwrÍݾÆ&;ã š2 §ù»=ý¨¡ë£#ÿÛj‹\—ÿ#®wç^ J?ä\û›WSä>Œk[È£2öœ_1ýžo©zÑš‡*×OKorñ^oƒ5£DþÉî„ì]°U6ò—›ÆLƒm¢s íÇÒÝüÿóžÎ/%Ôú í6¯©QÉ'9v¯ÇýÿA¾ ~é ;€#ìR2>¼h(Ç?-´}O‘—Ûbwè ~h瑪!Ž¥ïç•þâícücbÕ‹RrÖ‹Úo×µæÇê¼d}•N}L_åOŸÔ–¶1ÖæÿsÃùavwÞyçû ñ¼8Š“@¨gH›‹bïžsvòÁs¬·NgÂîje”“â×2E’нÖߺ>åˆÒF­ 7÷r_ÇM¦æ÷Ruþ.ðíù]ˆÈxžl†Dû”Õ*žš‰±†™aò'²_©á¹aìµ¢»ÒFm‹‚¹Žñ @¢Ñ¹ASš´É@S²á +ó=îÿÙÏ~VTÎxïÖÁnŠæïW_}uŽ‹á@Æbéüí⮋òߘ߄µyy\”ù°¢ç–ö´©oú /ÆPùd¼í—Í=8×N¸ŠÉÿoç:¼.1i;¨N±N¬Ï‰¢n¥?É*OýoêùèWd¡.n¨s/úäVú‰†/L©²‰ªRFl‡ñ4‹%d,Žg]kØÍ± Ïäôå«c®²gz—ÿ¿ÏYmµÕv̵ø1ì ‹‹«Ä”ýúZßÏÕÌ'ˆbãÈîŒóäX:ðdã,²bL²®yÁü€Nü ÷½7ß9y<æÐ9+cXæóW˜{å·ù¨§qB2˜jdr̹èñ„Œá|}Œdà'Û¦ƒ"ÄÁÒ²ýÎwsKŒý}ª ôB×=ò{©À˜§¥7¹~N¹GÕƒ^C6ÊA$HâøÑeç^Dg>¦YHó1cAŸ:u7và}Å&±a>VºÔL-jÍ‘]üƒQvI0•ý‚Œæ:vJ;÷ÜsÏgóï8ßa=¬ò’}î;7x^t÷×D&Êïêø›’Ú™¯r<{zli‡qotuïœM8ç›s'¿¥íZbúˆý²Ë.ûÄE]túyçwæÙgŸýùAMr÷€G_õÈ#lJI‰bíÆ£”ƒ±Zæíoû<¼)‘À‡>ô¡¡cLê¬ïOctË„Úï¼Kmmý)me¾ãýùM«ø§(Ï8Â@†ªQû9žD¾ ,ãD†çUâô¾âº3Ï<“QfÜ)rÓço±ÅëC"·os°\ ä™®‰²~±DÎŒšûVæ,á\F®/!c˹ãfÁŽ14GiÃÿà Ãà@£¼H¿¶| ÐþèãºLîí–ßs‚ê´\SKE Hãh‚N¡~íµ×~$¦þÉ /¼ðŒsÏ=÷ìû/œqÆžzê©§å:ýÕ'÷š<ëïxÇ‹åï.z⨢¸‡§ÿ'¡ÿF¡I3±¨”V Ði'žx"Þ4+À£:`¼”àYd§È7ý>ðÀ—-e­kò›¢ÞS¬f*ùÚl¹üòË7Nÿ>cû-‘¼þ”>Ý›?´§¤Œ}㘫 ç{u~ÚU’™*¹ö¨£ŽZß"îFy]Wúö2™ÖNÁ^¡Ïmþc8ßE¿»ÛäÐ9[&cÛÛ=C˳ÊýžƒJ)Æç¾q2'å;k·å7:1öÃt8í´Ó^C>Ieá±÷×òÌ!‡òÆÒï¹®­AÐÁì7›SÚñû¥SÑ›\WõOŸ8}8XÊ÷Q"™§jCC¯^$èhÐDÞóKߪîj§Sw¯ºêª†¦lB í›s{Tu„îâWÛAø½^Á(»¤Ìšcd…>,—9¹FóŸÑxÊáÙFVÜ;zÛÖ]×½Ä\”k>÷¹Ïi‡ÁçàéÇõ¼ð® ’ée~l¥~‘µjg8;tù-m7¢DvÞ8xCÀؼ#xwp`€aëEA·s~õüæ=aØAäû²a°zg³ÝxãÊCŽ#¢€ïÏoE2¼3ѶhŠÂl÷Å/~ñÓ­¶êJÄnM N#,9RcÆðþ–‚2Ü5=d|^–tíÛ®£(Õ«‹¨*j ëÞs>ƒØDÍú[Çå\Ì•ä˜68©!ãúrûØÇ”D­¯¶ßj«­º•¬M”Hðð„5þ—rZÎÙgŸ}DµÚ\Ita_‰h´o¼>õk­€ðù´L‘vÅ8¬íFì]l‘,0(”â•Áª16§Ô‡ò• ¡1êú“¨ˆƒÐn#ÔÇsÌfõ˜ã¾g<_J)gß2VçŠàQ#¿(l‚å!ך Ïïê(ÃØÆœüæ<ÚëCò›áÃOÎîõ)‰!ªwÏüŸfŸ EÚ‚qs?÷¯ÁJ‰ä›¾ƒ†è½l•«|';äÑsW<ŸÌG;~oÌDË`ß–÷È÷·ÜrËuÐ)dx~?Çüh+%àf(ëe¥mòBVžù‰O|bƒ:éë^œ µé¯”œs‡ÎmYÙ¿óòQcp‚ÀiéM®ήòOð¡n"_å¯Çp‚ÆSŒ!º0æ#@í»Î©ÁC¯¥»nÕ]×Ðeò›:ÝÀo¼bËÚ=e ha—Ær)M+‘1A-=Dß5”|;íþ8ß_°y« 2 ¯«ƒGûêT^‚ú''(¨ÎŠžàIcG2-û˜ù-m÷:Ä0@)7ñÎ`ÏB —Rr¦¼eðµÔQ#ðe leF”‡ÐŒø¼ßW®“våÁøP¨FYªƒà™óÁ‡‚F˜A½V;¥TƒPÃûK ­fŽ5º÷{ýô¯2ÞÙŠ LP÷„”N¸òÊ+?–ùSEKë\_ëÄ/‰P¼)¥§/rÙ}”)¢ÈÒa dБ9Á¸%¦bÐE˜[oL-´)Å~/¿9†Õ¸«c]»:·½öÚ‹âhoÍ믿þx×Ád¨œO€=Äñ:}úq”a~ð¦à­'Á!é“{¾4YÃ1ÚŒ8ýóŸÿ<‡ÁˆÔg%¢nJa¢´M¦´?¬pþùç˜1~¥*s9—3f´Ñ›L5i4ƒFNò½ÉBZÆ¿«RQDCœF—ƒ1xj<¯ò“Ÿ¼‹²ž~ÇÛd‚Ú.%P§þh§f:k¦zŠk”BËøšŒÏ¸ Œ§fóó{ÇŒûûÅÙ߯°ƒçl0/÷n²Ãdáx²Bx}&y[wÝu·ˆ|6st> ÝÐØ¸†T²ðwq2Ù'kz°LÍ|â`”’è\›ã)Æ ­éŒO´˜¶ÞÚቹíÊ&8ñ‡ÔÒ«,´ŒÃ˜G .àˆ~%cMùïH˜Hw£3¥JrFt÷›UöBË»’e½?íÈèÛ Z%&:TÄ(»4–ƒÈB¼D3¶€í£“ëµæŸ´EÖ× ¯¿ÁVmºé¦ä¾V ææ;;·†àcdUÊʯÆÁdYàÂÉÎü6†ƒPÞ](-í]>çåsù|ä#ëpYÅă!…nPUŒÃ%‰°žrÂþe`5RÂô—‹0‹"qc:ˆ².Ák$ŒÃ«}N>ùdŠN˜‡÷—û"¨¶(n#äúÁúž~tÒIœàPÀˆº‡sõÃØü™“ߢjÑ%–͆††Þáü’{e„ºå=-xlð°€"4[U„â ‹sÛ8ˆ:7òýÒ¡A›ú¹~hú“D!wg#¼¯R³ÕËeŸ>2 >9üœ0ný:¼r¿ÁÛ´@4^>Ƴ‰Jó]Ïè2>ãŠ)3ZšGFnÍoeNFtŒnÆÆýòùóço‡ýç'ê==ûæÛP.5Ú&òˤín1„ûû®D”cˆìzû]ADa]BÏ‘¸†LèǦœrËØ£ÝÊŒeÉDñ’¬»u¼ë¥ÌÚD¼‡z¨ìЬ¹×º 8Óïd ÝÐ߸úr TšÌ$Æýh‹Š,ÓÚï|ç;›•2‘ÝãDÓä¡ÌŸ4%*c¹ôÒK?àœ2Ĉ+‡:7X=AÆÍŽËXó›~ ¶´¿”/k`%²ž)½i²²`Nðˆ`Ô–.5sa­LMG :·ð‹ŒÐ/÷ j)o<ÝeTçŒì)¡~X{%££çteuv«8J´³žre¡úˆèW΃ÅÃÞo¿ýè {¢_l½ymdù–µ?iÝo¥Î–îÒך‰ú|El_3&Éo$½Ôã Gθõ™ßÒvW1¡ƒ(“Ô”³¦;«d ì®CA–_~ùU²jCŠBˆWXa†bAn, ÏAÄ€~Èý¤‚9Ÿá­Þsg?ûÙëkÇñ]a&Å^Ç}Ë÷ùAøÆ9[§öšë©œ›ß¢_w®~íÈš”0Þ0Ž”ˆ¢sîI¢?¿·}¦ÍŸç;CÁI0Þ¢x†Hôùÿ‚áRÇX"ç4‘¬så•WÖÊAКÏ8€õ=ó›ÐâÓ&æìßc=d|ÆËá0V„[6hçljϴƒàD† PcĪÓToÏoÁÈxÞPÆRO^³ãŽ;Z"k^ëŽüFïùc«…·L%k»@ÖáûÑGí^Õâ-ŧ(ä²ËAà:8àóˆ¦îº<Þãß:5ZÍœÓù]tm÷µQö{\·æškå%ó8ðâÄ9EAY1¦¾DæÎš zÎÁ}ÊŠ¶¡\Ÿ»šäNÖ{%ÃVŒ¹Ð( ïTå£ÉoÆÉEš«È<)÷OÔ*ó0ïB7wàpŠÞÔ’Š1Ï”ÞÐ3ŽJ´û¨`Ô–.Mè Rji&œuËÚdô¿Ðx"Ý—s èñ¦qFžßùûë^÷ºãó[–¼IË.¡Ýð¹ù>¢²9ä”Ù¥&pµ<×½R¶$ŸÎµßqô|½ÒqtûžÒ‡ùÚOöÝ”8‚ü¦ÏÆRËÂV^áiö“3|®òÖˆàå_ƒ™ßÒ·)9ˆRbjj“ÁjË,³L3±ÛR`c¹”š¨¸‹³¤¶[ÄÉ4ËTO?ýtØ@E‰PÎ{ÙË^¶U­Ÿ>÷¹Ïµñšó}ѵ6ÏfdßPÐD§¼rtÆZdÀX2$óJ¶Yí«(­ì#`Z4µW& }ÊSž‚î±í>ðÑ–û¸FŽ ²$tŸ¢Ì¢eç3Ä e`„¤öÿ<4h¶ºšÆb~3'@`74+t\ZökoÞÒK/½©Õ1µïì#DÇ™xm&²vÝuWmA@€Ðjø¾ùŽ6 ¹Œ†‚Êjôix™k+r3†q3ˆºZ-e@ ·Lð¢`ù¬´:¨ò¥”Êjú¦¤äÉ9îÍ¡7^¾,ï©®É\Ä—ò ñˆ!±¯ ¯÷, DeèÂùïίÑGÅ1c}ûð‰å}W¢×'h¡Ï+§Ôج*FÒÓ†‰ÒÇ¥TöÔ§>•lè;¥_/ }‘c¡Ùù]T“E´„ ‚ÑrOüØ(s ÍʻЂa®i `ŒÃ÷™ÏQzpîÅ_|Lö‘)4{+]ªôˆøjö¡ñ‚  Â’Q7å¿âXÈz¡Éð–ãÉÞÞ}µB°•j…hZù3-½)´Ô¼ÁÏi9ˆ\¿‚]úŸ’ÒaùM®ñ…Ìwê®Àj­µÖª›ž9ýg>ó™qð¥ä‡Oƽ^"ý/»©|Ðsý¶KUß²xƒ”½5ë|A)ݽ1û*çåûÆp¡¯{é‡û®WÝLn:¿Ù–uõ-U‰‹œ¯/e^†|á ý!£ôÄ=dÛl‘è¯1le "3Þ]ú÷òLT_æX–.^“ߘJ(·ÈÓ¥ÍúdN€±…ˆ—çXS*‚ú eáA9šž•T¯IÉ å (5Á5ÙE…òŽú²ö¥Ö1ºŸ7çñõ¯ý+µíYrÏõ뜃ú%oNHÚuô8©Cr.êƒìA´®4¡ô¢îÚ+[šl"¥R»ªý®ŸužÁ83GòY¨BT ’Rl\.Õ' úâsÅW¤œÏ.írö//%&l PìçDV?öØcww­¥N8÷Ê|Î{ZyðË©O†Åp162…}²‚çÂæ@¶."Ë ‹^ílUuƒ,ÑÉðä:¤ÍºÐÁŠ©œK?d˜[· ˜ñ“¡JÓ)ëMîAþð„sX6½M9ƒÈµ+x?S}Ž©Ý5§ˆ¿lŒ9sF©JœWƒÄDþgç¾äŽÁŠch–ç»Æ|%Zr9ÖØ¤š)”÷“á3GØá ô#/enT`242aáOÍ`9«ZñyÓM7}F_Ê¢ 6NÐ׆ÀcVDó(wˆAÐ4Ô¤Cáæ‘ !2Ød"tËHC`©8G°¶ú°ù†¡kÕ|2bƒ¶LDü­Dj?Úh£NÊoBÌ3¯“r϶1zgZ÷(Œh^ðôxÑc¶*žIâ[×'OJ§Ïƒ×Ý%ÊY|JåXÃŒ–ö \ÎûÅÍqÁü@ékçdg¹¯4[êlÙíœõ×_ŸÐ‹†Dw¾W£J&_ŠÞ¥>ŽŒ%#f¬Œœïx/J•¹U#ô |o¶ŒoË8‡9&‰Bëª+K˜‹ ¡Á¡‘ÑÚ&áüM–ÿ´Î/ÄÉ]PÚC‹gŒ`ÃC™1ä{ P†Dö5N"÷;—ìŽ%ó¡ën¡Í×’5^–kªaà÷YguÇË¡—[n¹ý²}ßêX¡ ¹U2ˆ+­šAg<¢ŸÏyÎs^•Eæ¾7y!»ôü¹èõ×òÝõ²ÆmZzS®WÞšÛ9ÁX¢‘Ãô“m èS/cèAÂ~u½Í[¡AÕ_ºk‘‹eœÚá$8Å5@îŒNäž,·íRÄ#- Ά¾ ;ûñ³,X!“øn bÿÎDå;ya#‡‘2åt]FçèrYx0üÅÉ‘õZ5¨4©:3{"ÖMŠ¢!7õ¹@d&’¢|Ê&B<<øÁ\Ä Ú0STÇFÌ}Ôå0^žPº?UÔó€aCXQ?p2ÊœQMÅÛio-;q85õÒÄ«Â=G0$¿ç)í·ÓTƲQF÷t/4©Jn¬C¥Ÿõž®gX8R%ýÐ/t "LôêÝž\î5ÊA”±6B€Œg´Îú5/ÀM ôvN[¹²éèC{Wí1ã{ ”ßî771ÂÎ76‘Þé«q£‹–ÊÊ)\➘>â‹L‹ áéüÝÑÑñ¦/4‰× †áIA{ûçüÀðö@!)…ƒÊÑLƒÄ|çj“ t¾ë1´­÷®¢Fš”—1ݤÊ%pNM•‡ò0´APm¥0mÌ 0‡âÈö (¡>·ûëÜ:f÷«†š€‰à\‹ÑÕ±2Úèrhê~Ãihùθ vjdŠ'Æå¾•6UhôÝ5>ÑÁqôjó ñl¼­öÇõÚÁ3catjDäžxVÝ'0šÚçðÁâhñC† ïõ¿<×nã'üŒÝ»Ê5èî¼WÕšpV9éÅ®B¿´QD¥õRÙÇônö p8üçÜdVäo¨ôCÿõ«,ù´ñDgòI~ýF+²æ:c˜ˆBݯfã]†–cüè³ã½2?'û ê ð^ªCðݸA_ñ©³á ; /µîM–ÉxÍ88oÂ>Çð…SCk×Í”Þà3z?!èW»lÙû×`*ºKvÑ“]Òº‡wó²Dö²~Ï+´ð]?ºì’`¤ pÕ7vŠ-iï«Çèá¶éú¾°WÚ⬆‚WäáÔ(/ÉöJ?kÀF«ìië%šÌê&;e2L½ÐÇ÷´.Bã zæ!w `¥ªQ)¥§8N9(‰ë²k«Â08@@X ­FuBÕPºw5<ö!šsÛ1™müG~‹&ŸVöë'%¢øŒ#øN´ëè³L UÖ§j`ô›B ÊY¯åô´±š¢Qo4Á¸dƫҽŒËøªâ›vÓÿiVÇÛæ ^uEÕÙ=¼Õþè÷¼@”ÂhÔ¬H;]BÛxÕQ1˜ŒA&ØøŽÆ"4¼V€/øo< Óö–sz¢[‘’x .ûÑ]ŒßyŒøNÑÑŠáXÐµç ª!u}5ví …þ2þÕè’‡*+Îqœ¬8n\îE^«œê3oƒ1xTu¦-ósÊXÈ€ãÚ WäÐUŸ@_õYÀhú€&dWŸôÍøÐÙ50¿Üoª,͆Þ?:ÇÎ<$o«rØe‹è {LEwÉ}f ?x€7dmé.Ú?þ¢ú’.»„7úHèyÕ7,„íjë ïÚ•Û¢<›q¬ÒWæ0ÎVFö¨@]±Gö-„ÉùäLàUl5ÝFCJ;7 \³~j®Íë:ÔŠKÝ ÑC;øÌqÕÚwב|ýÇ1Ùƒ@_÷7v40}EWŽ<’A}5ç×Oç´(ºÕXài"OUg\×–ù9ùÍ ¢ y ïÕ¹úÔ.9#§Ð–‰Xá£è³­WŽ7tð×xí«ýŸ ½1–Ç ûƒ‚ñ¶*‡]¶ˆ®²USÑ]Á º} OhƒOÆ\‚¡|ÇãÜâ—]r-ùp.®:ç~hÉ.té¡,jØy)¤g/ʼf3/Gî9‰#Ž8â­9—|qZ;»í ßæ fuÃ8žÍ {A9{=%äé y¡GĤmÇa”Ë1ŠLpk$NIìs¾ï¢¦¶®Ó>CìD‡Qb§( ¼c®óIÈœHÉ „%¼OŸkDO!Ý‹‚Oä ôK[C%×÷jäõÝýÑ·wCSÇ^æ'–>£ÓÜÀXô«…êk[øæ{ufmÞàÕX†³ö«öG[ÆPpͤŒ¯7ƒ¨tÃt¨Š„/”®ËiÖà@?ç”±k³É5¥ÝÞû•}Æ„÷è¡-J˨Í/ñ‰¦´‡Ïø9–êÇAè3y2v4Ð/ra|U¦í«ü®Æ´ž_ ]ÀSòÜ*êw2¿Ugze~NŽ1$ÆNèJ+ô!}ió/ðŸN×6ô í‡ôªŽ¥CÕÐ͆ÞLÆAT9ì²EÆC—¦¢»c9´¥ëŒ:ƒ_힣ïÜ Ë.U[çx[çœ[Û¶úN9À9=À#÷!x‡x$øÝ"xSð¶€ÃØ9Ø&à4ÈûÐe_²{æ¶έDÓ½òsÑÓ”4‘‘%ÄΫQeÅ6æä7ôîGÊï“ÁDx „Ä=]ãžÎë5æCÙÇXVæºÆ9Õ éW»Ÿ¾‹Bl¢ê¥ç´ÛÆ k2ÂùÕ¨ƒû=)@'OÚ}r›}…@Í ›šE å;Ô Å1爊ÐJ›½ãÕ‡‰RûÚt®Î’A&„”G$Õë ´‡ÖŒ8TEržkN@G™ãøS3¤:¶¹åc`À‹¹¥ÏúÊøƒV¿·?ñô¹mÀ«ÌÏÉ~¼w ÙGÛ*ÏõÓ¾XÔ`¬~º'}ÖF¯ :ë·ñún,xÞng&õf2¢Êa—-2&¶Ê6YÝÏA´u½ê.ÐaýèâÚ£YÕ¿ªs®³o,=TMèÕO¿µƒ·äŽ® zI»ï  ÞÈ"¶ d€ú­oÿRh2kˆ­ãRô^,•}•)µ” #«¨# ˜§¬^º?ØÇVhÏù¹FMÕàPF÷#`€è *Æ12 I-MaVUh‚D¹\£_Œm• Ê~FE¿´_ €{‰$(“60¼×±U§USxJ†¹5â5–¥m¡Wï†¦Ž£M/ÐV¿82ô©c®m³ïÕ ¡¥{«Ï^¸_WÚ}ªýA7ÂJQD4Œ;#B{XyâsNÀ°£c§Ÿ>Û³ž‡~•ÞÎGk47.Nʽ+Ï}â­~p”G¤?0ÎÚ\*oŒxhÔŽÞk ¯– Œ™¢¢’^ÝUúT^è3>á—LÆùúÔ…‡•¾Ô  :²Sež<ºYî2(öWôwöɾ´e¨êq־϶Þ躣?>Œ·U9ì²Eô”­²MVw{±vöFwÉiÍð˜NU½Ä‹^ѽ6¯*Ÿ]G¾ºt‘â}¯=òÛxé†~éËP°A Kæ$ö 8Nƒü ÀØ&}­4ù?ÊÌÂF±“Î÷Ãz£OÌÑ)Ç*0ŸP,Bø]Qï¡Ìa_o°¢W±ÜÏ>ÇÝ·¯Î§:–j$kÛ>ë÷v?}o—[Œ¥ö‹2a,farjD_¿ŽS¿ó0J_ª34F4K!ÐT_ÚtªßëuøâœêŒõCЯs\ƒ‡½c­Ç&RÌÚm¡¹±i§:€ª`è‚>è„•Îmš´ #ViRy\ƒíG¥aï½+¯ÝBRdŠWu>úˆÞmè‰Nú¡úUÇXR¼ ?ÈÚUqm¥O5Еúë´t]/ªüµån<™oëFû{••.m÷»Ê¶6ð¬fÕ©, ½©ÏDA þU9ìùnßc2ºküUVñïñ¯!5¨­¶*«m[*û*в-ו×ú=–Ý!{cÉ…kÜ“ #macro ( link $href $name ) #if ( ( $href.toLowerCase().startsWith("http") || $href.toLowerCase().startsWith("https") ) ) $name #else $name #end #end #macro ( banner $banner $id ) #if ( $banner ) #if( $banner.href ) #else #end #if( $banner.src ) #set ( $src = $banner.src ) #if ( ! ( $src.toLowerCase().startsWith("http") || $src.toLowerCase().startsWith("https") ) ) #set ( $src = $PathTool.calculateLink( $src, $relativePath ) ) #set ( $src = $src.replaceAll( "\\", "/" ) ) #end #if ( $banner.alt ) #set ( $alt = $banner.alt ) #else #set ( $alt = "" ) #end $alt #else $banner.name #end #if( $banner.href ) #else #end #end #end #macro ( links $links ) #set ( $counter = 0 ) #foreach( $item in $links ) #set ( $counter = $counter + 1 ) #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) ) #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) ) #link( $currentItemHref $item.name ) #if ( $links.size() > $counter ) | #end #end #end #macro ( breadcrumbs $breadcrumbs ) #set ( $counter = 0 ) #foreach( $item in $breadcrumbs ) #set ( $counter = $counter + 1 ) #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) ) #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) ) #if ( $currentItemHref == $alignedFileName || $currentItemHref == "" ) $item.name #else #link( $currentItemHref $item.name ) #end #if ( $breadcrumbs.size() > $counter ) > #end #end #end #macro ( displayTree $display $item ) #if ( $item && $item.items && $item.items.size() > 0 ) #foreach( $subitem in $item.items ) #set ( $subitemHref = $PathTool.calculateLink( $subitem.href, $relativePath ) ) #set ( $subitemHref = $subitemHref.replaceAll( "\\", "/" ) ) #if ( $alignedFileName == $subitemHref ) #set ( $display = true ) #end #displayTree( $display $subitem ) #end #end #end #macro ( menuItem $item ) #set ( $collapse = "none" ) #set ( $currentItemHref = $PathTool.calculateLink( $item.href, $relativePath ) ) #set ( $currentItemHref = $currentItemHref.replaceAll( "\\", "/" ) ) #if ( $item && $item.items && $item.items.size() > 0 ) #if ( $item.collapse == false ) #set ( $collapse = "expanded" ) #else ## By default collapsed #set ( $collapse = "collapsed" ) #end #set ( $display = false ) #displayTree( $display $item ) #if ( $alignedFileName == $currentItemHref || $display ) #set ( $collapse = "expanded" ) #end #end
  • #if ( $item.img ) #if ( ! ( $item.img.toLowerCase().startsWith("http") || $item.img.toLowerCase().startsWith("https") ) ) #set ( $src = $PathTool.calculateLink( $item.img, $relativePath ) ) #set ( $src = $src.replaceAll( "\\", "/" ) ) #else #end #end #if ( $alignedFileName == $currentItemHref ) $item.name #else #link( $currentItemHref $item.name ) #end #if ( $item && $item.items && $item.items.size() > 0 ) #if ( $collapse == "expanded" )
      #foreach( $subitem in $item.items ) #menuItem( $subitem ) #end
    #end #end
  • #end #macro ( mainMenu $menus ) #foreach( $menu in $menus ) #if ( $menu.name )
    $menu.name
    #end #if ( $menu.items && $menu.items.size() > 0 )
      #foreach( $item in $menu.items ) #menuItem( $item ) #end
    #end #end #end #macro ( copyright ) #if ( $project ) #set ( $currentYear = ${currentDate.year} + 1900 ) #if ( ${project.inceptionYear} && ( ${project.inceptionYear} != ${currentYear.toString()} ) ) ${project.inceptionYear}-${currentYear} #else ${currentYear} #end #if ( ${project.organization} && ${project.organization.name} ) ${project.organization.name} #end #end #end #macro ( publishDate $position $publishDate $version ) #if ( $publishDate && $publishDate.format ) #set ( $format = $publishDate.format ) #else #set ( $format = "yyyy-MM-dd" ) #end $dateFormat.applyPattern( $format ) #set ( $dateToday = $dateFormat.format( $currentDate ) ) #if ( $publishDate && $publishDate.position ) #set ( $datePosition = $publishDate.position ) #else #set ( $datePosition = "left" ) #end #if ( $version ) #if ( $version.position ) #set ( $versionPosition = $version.position ) #else #set ( $versionPosition = "left" ) #end #end #set ( $breadcrumbs = $decoration.body.breadcrumbs ) #set ( $links = $decoration.body.links ) #if ( $datePosition.equalsIgnoreCase( "right" ) && $links && $links.size() > 0 ) #set ( $prefix = " |" ) #else #set ( $prefix = "" ) #end #if ( $datePosition.equalsIgnoreCase( $position ) ) #if ( ( $datePosition.equalsIgnoreCase( "right" ) ) || ( $datePosition.equalsIgnoreCase( "bottom" ) ) ) $prefix $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday #if ( $versionPosition.equalsIgnoreCase( $position ) )  | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #end #elseif ( ( $datePosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $datePosition.equalsIgnoreCase( "navigation-top" ) ) )
    $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday #if ( $versionPosition.equalsIgnoreCase( $position ) )  | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #end
    #elseif ( $datePosition.equalsIgnoreCase("left") )
    $i18n.getString( "site-renderer", $locale, "template.lastpublished" ): $dateToday #if ( $versionPosition.equalsIgnoreCase( $position ) )  | $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #end #if ( $breadcrumbs && $breadcrumbs.size() > 0 ) | #breadcrumbs( $breadcrumbs ) #end
    #end #elseif ( $versionPosition.equalsIgnoreCase( $position ) ) #if ( ( $versionPosition.equalsIgnoreCase( "right" ) ) || ( $versionPosition.equalsIgnoreCase( "bottom" ) ) ) $prefix $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #elseif ( ( $versionPosition.equalsIgnoreCase( "navigation-bottom" ) ) || ( $versionPosition.equalsIgnoreCase( "navigation-top" ) ) )
    $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version}
    #elseif ( $versionPosition.equalsIgnoreCase("left") )
    $i18n.getString( "site-renderer", $locale, "template.version" ): ${project.version} #if ( $breadcrumbs && $breadcrumbs.size() > 0 ) | #breadcrumbs( $breadcrumbs ) #end
    #end #elseif ( $position.equalsIgnoreCase( "left" ) ) #if ( $breadcrumbs && $breadcrumbs.size() > 0 )
    #breadcrumbs( $breadcrumbs )
    #end #end #end #macro ( poweredByLogo $poweredBy ) #if( $poweredBy ) #foreach ($item in $poweredBy) #if( $item.href ) #set ( $href = $PathTool.calculateLink( $item.href, $relativePath ) ) #set ( $href = $href.replaceAll( "\\", "/" ) ) #else #set ( $href="http://maven.apache.org/" ) #end #if( $item.name ) #set ( $name = $item.name ) #else #set ( $name = $i18n.getString( "site-renderer", $locale, "template.builtby" ) ) #set ( $name = "${name} Maven" ) #end #if( $item.img ) #set ( $img = $item.img ) #else #set ( $img = "images/logos/maven-feather.png" ) #end #set ( $img = $PathTool.calculateLink( $img, $relativePath ) ) #set ( $img = $img.replaceAll( "\\", "/" ) ) $name #end #if( $poweredBy.isEmpty() ) $i18n.getString( #end #else $i18n.getString( #end #end $title #foreach( $author in $authors ) #end #if ( $decoration.body.head ) #foreach( $item in $decoration.body.head.getChildren() ) ## Workaround for DOXIA-150 due to a non-desired behaviour in p-u ## @see org.codehaus.plexus.util.xml.Xpp3Dom#toString() ## @see org.codehaus.plexus.util.xml.Xpp3Dom#toUnescapedString() #set ( $documentHeader = "" ) #set ( $documentHeader = $documentHeader.replaceAll( "\\", "" ) ) #if ( $item.name == "script" ) $StringUtils.replace( $item.toUnescapedString(), $documentHeader, "" ) #else $StringUtils.replace( $item.toString(), $documentHeader, "" ) #end #end #end
    $bodyContent

    fest-reflect-fest-reflect-1.4.1/src/site/site.xml000066400000000000000000000012311211245343200216740ustar00rootroot00000000000000 org.easytesting fest-site-skin 1.0 FEST-Reflect /images/fest-reflect.png index.php fest-reflect-fest-reflect-1.4.1/src/site/xdoc/000077500000000000000000000000001211245343200211465ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/site/xdoc/index.xml000066400000000000000000000005231211245343200227770ustar00rootroot00000000000000 Welcome

    You are being redirected to the wiki page.

    fest-reflect-fest-reflect-1.4.1/src/test/000077500000000000000000000000001211245343200202245ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/000077500000000000000000000000001211245343200211455ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/000077500000000000000000000000001211245343200217345ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/000077500000000000000000000000001211245343200226755ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/000077500000000000000000000000001211245343200243215ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/Jedi.java000066400000000000000000000053271211245343200260460ustar00rootroot00000000000000/* * Created on May 18, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect; import java.util.ArrayList; import java.util.List; /** * Understands a Jedi. * * @author Alex Ruiz */ public class Jedi extends Person { private static List commonPowers = new ArrayList(); private final List powers = new ArrayList(); private boolean master; public Jedi(String name) { super(name); } public void addPower(String power) { powers.add(power); } public String powerAt(int index) { return powers.get(index); } public int powerCount() { return powers.size(); } public void clearPowers() { powers.clear(); } public void makeMaster() { master = true; } public List powers() { return getPowers(); } public List getPowers() { return new ArrayList(powers); } public void setPowers(List newPowers) { powers.clear(); powers.addAll(newPowers); } public List powersThatStartWith(String prefix) { List sub = new ArrayList(); for (String power : powers) if (power != null && power.startsWith(prefix)) sub.add(power); return sub; } public boolean isMaster() { return master; } public void throwRuntimeException() { throw new IllegalStateException("Somehow I got in an illegal state"); } public void throwCheckedException() throws Exception { throw new Exception("I don't know what's wrong"); } public static void addCommonPower(String power) { commonPowers.add(power); } public static String commonPowerAt(int index) { return commonPowers.get(index); } public static int commonPowerCount() { return commonPowers.size(); } public static void clearCommonPowers() { commonPowers.clear(); } public static List commonPowers() { return new ArrayList(commonPowers); } public static List commonPowersThatStartWith(String prefix) { List sub = new ArrayList(); for (String power : commonPowers) if (power != null && power.startsWith(prefix)) sub.add(power); return sub; } }fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/Person.java000066400000000000000000000025351211245343200264370ustar00rootroot00000000000000/* * Created on May 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect; /** * Understands a person. * * @author Yvonne Wang */ public class Person { private static int count; private String name; public Person() {} public Person(String name) { setName(name); } public Person(int name) { throw new IllegalArgumentException("The name of a person cannot be a number"); } public Person(Person person) throws Exception { throw new Exception("A person cannot be created from another person"); } public String getName() { return name; } public void setName(String name) { this.name = name; } public static int getCount() { return count; } public static void setCount(int count) { Person.count = count; } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/beanproperty/000077500000000000000000000000001211245343200270335ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/beanproperty/Property_Test.java000066400000000000000000000126411211245343200325250ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.beanproperty; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.beans.PropertyDescriptor; import java.util.List; import org.junit.Before; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.Person; import org.fest.reflect.reference.TypeRef; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for accessing properties. * * @author Alex Ruiz */ public class Property_Test { private Person person; @Before public void setUp() { person = new Person("Luke"); } @Test public void should_throw_error_if_property_name_is_null() { expectNullPointerException("The name of the property to access should not be null").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess(null); } }); } @Test public void should_throw_error_if_property_name_is_empty() { expectIllegalArgumentException("The name of the property to access should not be empty").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess(""); } }); } @Test public void should_throw_error_if_property_type_is_null() { expectNullPointerException("The type of the property to access should not be null").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess("name").ofType((Class) null); } }); } @Test public void should_throw_error_if_target_is_null() { expectNullPointerException("Target should not be null").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess("name").ofType(String.class).in(null); } }); } @Test public void should_get_property_value() { String personName = PropertyName.startPropertyAccess("name").ofType(String.class).in(person).get(); assertEquals("Luke", personName); } @Test public void should_get_property_value_defined_in_object_class() { Class personClass = PropertyName.startPropertyAccess("class").ofType(Class.class).in(person).get(); assertEquals(Person.class, personClass); } @Test public void should_set_property_value() { PropertyName.startPropertyAccess("name").ofType(String.class).in(person).set("Leia"); assertEquals("Leia", person.getName()); } @Test public void should_return_real_property() { PropertyDescriptor property = PropertyName.startPropertyAccess("name").ofType(String.class).in(person).info(); assertNotNull(property); assertEquals("name", property.getName()); assertEquals(String.class, property.getPropertyType()); } @Test public void should_throw_error_if_wrong_property_type_was_specified() { String message = "The type of the property 'name' in org.fest.reflect.Person should be but was "; expectReflectionError(message).on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess("name").ofType(Integer.class).in(person).get(); } }); } @Test public void should_throw_error_if_property_name_is_invalid() { expectReflectionError("Unable to find property 'age' in org.fest.reflect.Person").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess("age").ofType(Integer.class).in(person); } }); } @Test public void should_get_property_in_super_type() { Jedi jedi = new Jedi("Yoda"); String jediName = PropertyName.startPropertyAccess("name").ofType(String.class).in(jedi).get(); assertEquals("Yoda", jediName); } @Test public void should_throw_error_if_TypeRef_is_null() { expectNullPointerException("The type reference of the property to access should not be null").on(new CodeToTest() { public void run() { PropertyName.startPropertyAccess("name").ofType((TypeRef) null); } }); } @Test public void should_use_TypeRef_to_read_property() { Jedi jedi = new Jedi("Yoda"); jedi.addPower("heal"); List powers = PropertyName.startPropertyAccess("powers").ofType(new TypeRef>() {}).in(jedi).get(); assertEquals(1, powers.size()); assertEquals("heal", powers.get(0)); } @Test public void should_use_TypeRef_to_write_property() { Jedi jedi = new Jedi("Yoda"); List powers = newArrayList("heal"); PropertyName.startPropertyAccess("powers").ofType(new TypeRef>() {}).in(jedi).set(powers); assertEquals(1, jedi.powers().size()); assertEquals("heal", jedi.powers().get(0)); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/constructor/000077500000000000000000000000001211245343200267065ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/constructor/Constructor_Test.java000066400000000000000000000076141211245343200331050ustar00rootroot00000000000000/* * Created on May 17, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.constructor; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.lang.reflect.Constructor; import org.junit.Test; import org.fest.reflect.Person; import org.fest.reflect.exception.ReflectionError; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for constructors. * * @author Alex Ruiz * @author Yvonne Wang */ public class Constructor_Test { @Test public void should_create_new_instance_with_default_constructor() { Person person = TargetType.startConstructorAccess().in(Person.class).newInstance(); assertNotNull(person); assertNull(person.getName()); } @Test public void should_create_new_instance_using_given_constructor_parameters() { Person person = TargetType.startConstructorAccess().withParameterTypes(String.class).in(Person.class).newInstance("Yoda"); assertNotNull(person); assertEquals("Yoda", person.getName()); } @Test public void should_return_real_constructor() { Constructor constructor = TargetType.startConstructorAccess().withParameterTypes(String.class).in(Person.class) .info(); assertNotNull(constructor); Class[] parameterTypes = constructor.getParameterTypes(); assertEquals(1, parameterTypes.length); assertEquals(String.class, parameterTypes[0]); } @Test public void should_throw_error_if_parameter_type_array_is_null() { expectNullPointerException("The array of parameter types should not be null").on(new CodeToTest() { public void run() { TargetType.startConstructorAccess().withParameterTypes((Class[]) null).in(Person.class).info(); } }); } @Test(expected = ReflectionError.class) public void should_throw_error_if_constructor_was_not_found() { Class illegalType = Integer.class; TargetType.startConstructorAccess().withParameterTypes(illegalType).in(Person.class); } @Test(expected = IllegalArgumentException.class) public void should_throw_error_if_instance_was_not_created() { int illegalArg = 8; TargetType.startConstructorAccess().withParameterTypes(String.class).in(Person.class).newInstance(illegalArg); } @Test public void should_rethrow_RuntimeException_thrown_by_constructor() { expectIllegalArgumentException("The name of a person cannot be a number").on(new CodeToTest() { public void run() { TargetType.startConstructorAccess().withParameterTypes(int.class).in(Person.class).newInstance(8); } }); } @Test public void should_wrap_with_a_ReflectionError_the_checked_Exception_thrown_by_constructor() { try { TargetType.startConstructorAccess().withParameterTypes(Person.class).in(Person.class).newInstance(new Person()); fail("Expecting an ReflectionError"); } catch (ReflectionError e) { Throwable cause = e.getCause(); assertTrue(cause instanceof Exception); assertEquals("A person cannot be created from another person", cause.getMessage()); } } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/core/000077500000000000000000000000001211245343200252515ustar00rootroot00000000000000FEST68_CatchingWrongExceptions_Test.java000066400000000000000000000034271211245343200346400ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/core/* * Created on Mar 19, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.core; import static org.fest.reflect.core.Reflection.constructor; import static org.fest.reflect.core.Reflection.method; import org.junit.Test; /** * Tests for FEST-68. * * @author Francis ANDRE * @author Alex Ruiz */ public class FEST68_CatchingWrongExceptions_Test { @Test(expected = MyRuntimeException.class) public void should_not_catch_RuntimeException_when_calling_method() { Main main = new Main(); method("set").in(main).invoke(); } @Test(expected = MyRuntimeException.class) public void should_not_catch_RuntimeException_when_calling_constructor() { constructor().withParameterTypes(String.class).in(Main.class).newInstance("Hello"); } static class MyRuntimeException extends RuntimeException { private static final long serialVersionUID = 1L; public MyRuntimeException(String text) { super(text); } } public static class Main { public Main() {} public Main(String hello) { throw new MyRuntimeException("set"); } public void set() { throw new MyRuntimeException("set"); } } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/core/Reflection_Test.java000066400000000000000000000047721211245343200312170ustar00rootroot00000000000000/* * Created on May 18, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.core; import static org.junit.Assert.*; import org.junit.Test; import org.fest.reflect.beanproperty.PropertyName; import org.fest.reflect.constructor.TargetType; import org.fest.reflect.field.FieldName; import org.fest.reflect.field.StaticFieldName; import org.fest.reflect.innerclass.StaticInnerClassName; import org.fest.reflect.method.MethodName; import org.fest.reflect.method.StaticMethodName; import org.fest.reflect.type.Type; /** * Tests for {@link Reflection}. * * @author Alex Ruiz * @author Yvonne Wang */ public class Reflection_Test { @Test public void should_return_fluent_interface_for_constructor() { verifyTypesAreEqual(TargetType.class, Reflection.constructor()); } @Test public void should_return_fluent_interface_for_field() { verifyTypesAreEqual(FieldName.class, Reflection.field("foo")); } @Test public void should_return_fluent_interface_for_static_field() { verifyTypesAreEqual(StaticFieldName.class, Reflection.staticField("foo")); } @Test public void should_return_fluent_interface_for_method() { verifyTypesAreEqual(MethodName.class, Reflection.method("foo")); } @Test public void should_return_fluent_interface_for_static_method() { verifyTypesAreEqual(StaticMethodName.class, Reflection.staticMethod("foo")); } @Test public void should_return_fluent_interface_for_type() { verifyTypesAreEqual(Type.class, Reflection.type("foo")); } @Test public void should_return_fluent_interface_for_static_inner_class() { verifyTypesAreEqual(StaticInnerClassName.class, Reflection.staticInnerClass("foo")); } @Test public void should_return_fluent_interface_for_property() { verifyTypesAreEqual(PropertyName.class, Reflection.property("foo")); } private void verifyTypesAreEqual(Class expected, Object o) { assertEquals(expected, o.getClass()); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/000077500000000000000000000000001211245343200254045ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/FieldDecoratorCombinedTest.java000066400000000000000000000122361211245343200334420ustar00rootroot00000000000000/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.core.Reflection.field; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; /** * Tests returning decorator result in case of a decorator exceptions * @author Ivan Hristov * */ public class FieldDecoratorCombinedTest { public interface IUploadFileService { Boolean upload(String file, String destination) throws CustomeException; } public interface INotificationService { void notify(String msg); } @SuppressWarnings("serial") public class CustomeException extends RuntimeException { public CustomeException() { super("This is a test exception"); } } private class FileManager { private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/"; private final IUploadFileService uploadFileService; private INotificationService notificationService; public FileManager() { this.uploadFileService = new IUploadFileService() { public Boolean upload(String file, String destination) { return false; } }; } public void manage(String fileName) { notificationService.notify("Upload successful? : " + uploadFileService.upload(fileName, DEFAULT_DESTINATION)); } } @Test public void should_pre_decorate_field_returning_decorator_result_ignoring_custom_exception_in_decorator() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); when(uploadFileServiceMock.upload(anyString(), anyString())).thenThrow(new CustomeException()); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).preDecorateWith(uploadFileServiceMock)// .returningDecoratorResult().ignoringDecoratorExceptionsOfType(CustomeException.class); field("notificationService").ofType(INotificationService.class)// .in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq("Upload successful? : null")); } @Test public void should_post_decorate_field_returning_decorator_result_ignoring_decorator_exceptions() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); when(uploadFileServiceMock.upload(anyString(), anyString())).thenThrow(new RuntimeException()); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).postDecorateWith(uploadFileServiceMock)// .returningDecoratorResult().ignoringDecoratorExceptions(); field("notificationService").ofType(INotificationService.class)// .in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq("Upload successful? : null")); } @Test public void should_pre_and_post_decorate_field_returning_decorator_result_ignoring_decorator_exceptions() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); when(uploadFileServiceMock.upload(anyString(), anyString())).thenThrow(new RuntimeException()).thenThrow( new CustomeException()); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager).preDecorateWith(uploadFileServiceMock) .ignoringDecoratorExceptions().returningDecoratorResult().postDecorateWith(uploadFileServiceMock) .ignoringDecoratorExceptionsOfType(CustomeException.class).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(2)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq("Upload successful? : null")); } } FieldDecoratorIgnoreExceptionTest.java000066400000000000000000000164551211245343200347540ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.core.Reflection.field; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import java.net.SocketTimeoutException; import org.junit.Rule; import org.junit.Test; import org.junit.matchers.JUnitMatchers; import org.junit.rules.ExpectedException; /** * * @author Ivan Hristov * */ public class FieldDecoratorIgnoreExceptionTest { @Rule public ExpectedException expectedException = ExpectedException.none(); public interface IUploadFileService { Boolean upload(String file, String destination) throws SocketTimeoutException; } public interface INotifierService { void notify(String msg); } private class FileManager { private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/"; private final IUploadFileService uploadFileService; private INotifierService notifierService; public FileManager() { this.uploadFileService = new IUploadFileService() { public Boolean upload(String file, String destination) { return false; } }; } public void manage(String fileName) throws SocketTimeoutException { if (uploadFileService.upload(fileName, DEFAULT_DESTINATION)) { System.out.println("File " + fileName + " sent to " + DEFAULT_DESTINATION); } else { notifierService.notify("Unable to send msg!"); } } } @Test public void should_not_ignore_pre_decorator_exceptions() throws SocketTimeoutException { // GIVEN expectedException.expect(SocketTimeoutException.class); String expectedExceptionMsg = "Expected test exception"; expectedException.expectMessage(JUnitMatchers.containsString(expectedExceptionMsg)); IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotifierService notifierServiceMock = mock(INotifierService.class); when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenThrow(new SocketTimeoutException(expectedExceptionMsg)); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).preDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions(); field("notifierService").ofType(INotifierService.class).in(fileManager).set(notifierServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN there should be an exception } @Test public void should_not_ignore_post_decorator_exceptions() throws SocketTimeoutException { // GIVEN expectedException.expect(SocketTimeoutException.class); String expectedExceptionMsg = "Expected test exception"; expectedException.expectMessage(JUnitMatchers.containsString(expectedExceptionMsg)); IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotifierService notifierServiceMock = mock(INotifierService.class); when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenThrow(new SocketTimeoutException(expectedExceptionMsg)); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).postDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions(); field("notifierService").ofType(INotifierService.class).in(fileManager).set(notifierServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN there should be an exception } @Test public void should_pre_decorate_field_ignoring_decorator_exceptions() throws SocketTimeoutException { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotifierService notifierServiceMock = mock(INotifierService.class); when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenThrow(new RuntimeException("Expected test exception")); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).preDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions(); field("notifierService").ofType(INotifierService.class).in(fileManager).set(notifierServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(notifierServiceMock, times(1)).notify(eq("Unable to send msg!")); } @Test public void should_post_decorate_field_ignoring_decorator_exceptions() throws SocketTimeoutException { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotifierService notifierServiceMock = mock(INotifierService.class); when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenThrow(new RuntimeException("Expected test exception")); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).postDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions(); field("notifierService").ofType(INotifierService.class).in(fileManager).set(notifierServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); verify(notifierServiceMock, times(1)).notify(eq("Unable to send msg!")); } @Test public void should_pre_and_post_decorate_field_ignoring_decorator_exceptions() throws SocketTimeoutException { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotifierService notifierServiceMock = mock(INotifierService.class); when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenThrow(new SocketTimeoutException("Expected test exception"))// .thenThrow(new RuntimeException("Expected test exception"))// .thenThrow(new RuntimeException("Expected test exception")); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager)// .preDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions()// .postDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptions()// .preDecorateWith(uploadFileServiceMock).ignoringDecoratorExceptionsOfType(SocketTimeoutException.class); field("notifierService").ofType(INotifierService.class).in(fileManager).set(notifierServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(3)).upload(eq("testFileName"), anyString()); verify(notifierServiceMock, times(1)).notify(eq("Unable to send msg!")); } } FieldDecoratorReturningDecoratorResultTest.java000066400000000000000000000177241211245343200366710ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/* * Created on Mar 20, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.core.Reflection.field; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; /** * * @author Ivan Hristov * */ public class FieldDecoratorReturningDecoratorResultTest { public interface IUploadFileService { String upload(String file, String destination); } public interface INotificationService { void notify(String msg); } private class FileManager { private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/"; private final IUploadFileService uploadFileService; private INotificationService notificationService; public FileManager() { this.uploadFileService = new IUploadFileService() { public String upload(String file, String destination) { return "Default result"; } }; } public void manage(String fileName) { notificationService.notify(uploadFileService.upload(fileName, DEFAULT_DESTINATION)); } } @Test public void should_pre_decorate_field_and_return_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "pre-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString())).thenReturn(expectedResult); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).preDecorateWith(uploadFileServiceMock).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } @Test public void should_post_decorate_field_and_return_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "post-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString())).thenReturn(expectedResult); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).postDecorateWith(uploadFileServiceMock).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } @Test public void should_pre_and_post_decorate_field_and_return_pre_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "pre-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenReturn(expectedResult).thenReturn("post-decorator result"); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager)// .preDecorateWith(uploadFileServiceMock).returningDecoratorResult().postDecorateWith(uploadFileServiceMock); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(2)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } @Test public void should_pre_and_post_decorate_field_and_return_post_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "post-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString())).thenReturn("pre-decorator result").thenReturn(expectedResult); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager)// .preDecorateWith(uploadFileServiceMock).postDecorateWith(uploadFileServiceMock).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(2)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } @Test public void should_pre_and_post_decorate_field_both_returning_results_but_return_post_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "post-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenReturn("pre-decorator result").thenReturn(expectedResult); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager)// .preDecorateWith(uploadFileServiceMock).returningDecoratorResult()// .postDecorateWith(uploadFileServiceMock).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(2)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } @Test public void should_pre_and_post_decorate_field_both_returning_results_but_return_pre_decorator_result() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); INotificationService notificationServiceMock = mock(INotificationService.class); String expectedResult = "pre-decorator result"; when(uploadFileServiceMock.upload(anyString(), anyString()))// .thenReturn(expectedResult).thenReturn("post-decorator result"); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager)// .postDecorateWith(uploadFileServiceMock).returningDecoratorResult()// .preDecorateWith(uploadFileServiceMock).returningDecoratorResult(); field("notificationService").ofType(INotificationService.class).in(fileManager).set(notificationServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(2)).upload(eq("testFileName"), anyString()); verify(notificationServiceMock, times(1)).notify(eq(expectedResult)); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/FieldDecoratorTest.java000066400000000000000000000127231211245343200320020ustar00rootroot00000000000000/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.core.Reflection.field; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; import org.mockito.InOrder; /** * * @author Ivan Hristov * */ public class FieldDecoratorTest { private static class LogMyName { private final ILogger logger = new MySmartLogger(this.getClass()); private final String name; public LogMyName(String name) { this.name = name; } public void logMyName() { logger.info(name); } } private static class MySmartLogger implements ILogger { private final Class _clazz; public MySmartLogger(Class _clazz) { this._clazz = _clazz; } public void info(String infoStr) { System.out.println(_clazz.getSimpleName() + " : " + infoStr); } } public interface ILogger { public void info(String infoStr); } @Test public void should_pre_decorate_field() { // GIVEN ILogger mySmartLoggerMock = mock(ILogger.class); LogMyName logMyName = new LogMyName("FEST"); field("logger").ofType(ILogger.class).in(logMyName).preDecorateWith(mySmartLoggerMock); // WHEN logMyName.logMyName(); // THEN verify(mySmartLoggerMock, times(1)).info(eq("FEST")); } public interface IUploadFileService { boolean upload(String file, String destination); } private class FileManager { private static final String DEFAULT_DESTINATION = "http://example.org/default/destination/"; private final IUploadFileService uploadFileService; public FileManager() { this.uploadFileService = new IUploadFileService() { public boolean upload(String file, String destination) { return false; } }; } public void manage(String fileName) { if (uploadFileService.upload(fileName, DEFAULT_DESTINATION)) { System.out.println("File " + fileName + " sent to " + DEFAULT_DESTINATION); } else { System.out.println("Unable to sent " + fileName + " to " + DEFAULT_DESTINATION); } } } @Test public void should_attach_two_pre_decorators() { // GIVEN IUploadFileService firstUploadFileServiceMock = mock(IUploadFileService.class); IUploadFileService secondUploadFileServiceMock = mock(IUploadFileService.class); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).preDecorateWith(firstUploadFileServiceMock).preDecorateWith(secondUploadFileServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN InOrder inOrder = inOrder(firstUploadFileServiceMock, secondUploadFileServiceMock); inOrder.verify(secondUploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); inOrder.verify(firstUploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); } @Test public void should_post_decorate_field() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager).postDecorateWith(uploadFileServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); } @Test public void should_attach_two_post_decorators() { // GIVEN IUploadFileService firstUploadFileServiceMock = mock(IUploadFileService.class); IUploadFileService secondUploadFileServiceMock = mock(IUploadFileService.class); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class)// .in(fileManager).postDecorateWith(firstUploadFileServiceMock).postDecorateWith(secondUploadFileServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN InOrder inOrder = inOrder(firstUploadFileServiceMock, secondUploadFileServiceMock); inOrder.verify(firstUploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); inOrder.verify(secondUploadFileServiceMock, times(1)).upload(eq("testFileName"), anyString()); } @Test public void should_pre_and_post_decorate_field() { // GIVEN IUploadFileService uploadFileServiceMock = mock(IUploadFileService.class); FileManager fileManager = new FileManager(); field("uploadFileService").ofType(IUploadFileService.class).in(fileManager) // .preDecorateWith(uploadFileServiceMock).postDecorateWith(uploadFileServiceMock).preDecorateWith(uploadFileServiceMock); // WHEN String fileName = "testFileName"; fileManager.manage(fileName); // THEN verify(uploadFileServiceMock, times(3)).upload(eq("testFileName"), anyString()); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/Field_field_Test.java000066400000000000000000000117661211245343200314470ustar00rootroot00000000000000/* * Created on May 18, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.List; import org.junit.Before; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.Person; import org.fest.reflect.reference.TypeRef; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for accessing fields. * * @author Alex Ruiz */ public class Field_field_Test { private Person person; @Before public void setUp() { person = new Person("Luke"); } @Test public void should_throw_error_if_field_name_is_null() { expectNullPointerException("The name of the field to access should not be null").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess(null); } }); } @Test public void should_throw_error_if_field_name_is_empty() { expectIllegalArgumentException("The name of the field to access should not be empty").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess(""); } }); } @Test public void should_throw_error_if_field_type_is_null() { expectNullPointerException("The type of the field to access should not be null").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess("name").ofType((Class) null); } }); } @Test public void should_throw_error_if_target_is_null() { expectNullPointerException("Target should not be null").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess("name").ofType(String.class).in(null); } }); } @Test public void should_get_field_value() { String personName = FieldName.beginFieldAccess("name").ofType(String.class).in(person).get(); assertEquals("Luke", personName); } @Test public void should_set_field_value() { FieldName.beginFieldAccess("name").ofType(String.class).in(person).set("Leia"); assertEquals("Leia", person.getName()); } @Test public void should_return_real_field() { java.lang.reflect.Field field = FieldName.beginFieldAccess("name").ofType(String.class).in(person).info(); assertNotNull(field); assertEquals("name", field.getName()); assertEquals(String.class, field.getType()); } @Test public void should_throw_error_if_wrong_field_type_was_specified() { String msg = "The type of the field 'name' in org.fest.reflect.Person should be but was "; expectReflectionError(msg).on(new CodeToTest() { public void run() { FieldName.beginFieldAccess("name").ofType(Integer.class).in(person).get(); } }); } @Test public void should_throw_error_if_field_name_is_invalid() { expectReflectionError("Unable to find field 'age' in org.fest.reflect.Person").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess("age").ofType(Integer.class).in(person); } }); } @Test public void should_get_field_in_super_type() { Jedi jedi = new Jedi("Yoda"); String jediName = FieldName.beginFieldAccess("name").ofType(String.class).in(jedi).get(); assertEquals("Yoda", jediName); } @Test public void should_throw_error_if_TypeRef_is_null() { expectNullPointerException("The type reference of the field to access should not be null").on(new CodeToTest() { public void run() { FieldName.beginFieldAccess("name").ofType((TypeRef) null); } }); } @Test public void should_use_TypeRef_to_read_field() { Jedi jedi = new Jedi("Yoda"); jedi.addPower("heal"); List powers = FieldName.beginFieldAccess("powers").ofType(new TypeRef>() {}).in(jedi).get(); assertEquals(1, powers.size()); assertEquals("heal", powers.get(0)); } @Test public void should_use_TypeRef_to_write_field() { Jedi jedi = new Jedi("Yoda"); List powers = newArrayList("heal"); FieldName.beginFieldAccess("powers").ofType(new TypeRef>() {}).in(jedi).set(powers); assertEquals(1, jedi.powers().size()); assertEquals("heal", jedi.powers().get(0)); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/Field_staticField_Test.java000066400000000000000000000121701211245343200326050ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.List; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.Person; import org.fest.reflect.reference.TypeRef; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for accessing static fields. * * @author Alex Ruiz */ public class Field_staticField_Test { @Test public void should_throw_error_if_static_field_name_is_null() { expectNullPointerException("The name of the static field to access should not be null").on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess(null); } }); } @Test public void should_throw_error_if_static_field_name_is_empty() { expectIllegalArgumentException("The name of the static field to access should not be empty").on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess(""); } }); } @Test public void should_throw_error_if_static_field_type_is_null() { expectNullPointerException("The type of the static field to access should not be null").on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess("name").ofType((Class) null); } }); } @Test public void should_throw_error_if_target_is_null() { expectNullPointerException("Target should not be null").on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess("age").ofType(int.class).in(null); } }); } @Test public void should_get_static_field_value() { Person.setCount(6); int count = StaticFieldName.beginStaticFieldAccess("count").ofType(int.class).in(Person.class).get(); assertEquals(6, count); } @Test public void should_set_static_field_value() { StaticFieldName.beginStaticFieldAccess("count").ofType(int.class).in(Person.class).set(8); assertEquals(8, Person.getCount()); } @Test public void should_return_real_static_field() { java.lang.reflect.Field field = StaticFieldName.beginStaticFieldAccess("count").ofType(int.class).in(Person.class).info(); assertNotNull(field); assertEquals("count", field.getName()); assertEquals(int.class, field.getType()); } @Test public void should_throw_error_if_wrong_static_field_type_was_specified() { String msg = "The type of the field 'count' in org.fest.reflect.Person should be but was "; expectReflectionError(msg).on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess("count").ofType(Float.class).in(Person.class).get(); } }); } @Test public void should_throw_error_if_static_field_name_is_invalid() { expectReflectionError("Unable to find field 'age' in org.fest.reflect.Person").on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess("age").ofType(int.class).in(Person.class); } }); } @Test public void should_get_static_field_in_super_type() { Person.setCount(8); int count = StaticFieldName.beginStaticFieldAccess("count").ofType(int.class).in(Person.class).get(); assertEquals(8, count); } @Test public void should_throw_error_if_TypeRef_is_null() { String msg = "The type reference of the static field to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { StaticFieldName.beginStaticFieldAccess("name").ofType((TypeRef) null); } }); } @Test public void should_use_TypeRef_to_read_static_field() { Jedi.addCommonPower("jump"); List powers = StaticFieldName.beginStaticFieldAccess("commonPowers").ofType(new TypeRef>() {}) .in(Jedi.class).get(); assertEquals(1, powers.size()); assertEquals("jump", powers.get(0)); } @Test public void should_use_TypeRef_to_write_static_field() { List powers = newArrayList("jump"); StaticFieldName.beginStaticFieldAccess("commonPowers").ofType(new TypeRef>() {}).in(Jedi.class).set(powers); assertEquals(1, Jedi.commonPowers().size()); assertEquals("jump", Jedi.commonPowers().get(0)); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/NestedFieldTest.java000066400000000000000000000123041211245343200312750ustar00rootroot00000000000000/* * Created on Apr 8, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field; import static org.fest.reflect.core.Reflection.field; import static org.fest.util.Lists.newArrayList; import static org.junit.Assert.assertSame; import static org.mockito.Mockito.*; import java.util.List; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.matchers.JUnitMatchers; import org.junit.rules.ExpectedException; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.reference.TypeRef; /** * @author Ivan Hristov * */ public class NestedFieldTest { @Rule public ExpectedException expectedException = ExpectedException.none(); private static final class BusinessService { private final NotificationService notificationService; public BusinessService() { this.notificationService = new NotificationService(); } public void doLogic() { notificationService.save(); } public NotificationService getNotificationService() { return notificationService; } // ... } private static final class NotificationService { private final Logger logger = new Logger(); private final IClientStatusDao clientStatusDao; public NotificationService() { this.clientStatusDao = new ClientStatusDao(); } // ... public void save() { clientStatusDao.update(); } public Logger getLogger() { return logger; } } private static class Logger { // ... } private static interface IClientStatusDao { void update(); } private static class ClientStatusDao implements IClientStatusDao { private final Session session; @SuppressWarnings("unused") private final List listOfNames = newArrayList("Ivan", "Joel", "Alex"); public ClientStatusDao() { this.session = new SessionImpl(); } public void update() { session.manageSession(); } } private static class SessionImpl implements Session { private final SessionMonitor sessionMonitor = new SessionMonitor(); public void manageSession() { sessionMonitor.monitor(); // logic goes here } } private static interface Session { void manageSession(); } private static class SessionMonitor { public void monitor() { // monitoring logic here } } @Test public void shouldSetOneLevelNestedLoggerField() { // GIVEN BusinessService businessService = new BusinessService(); Logger loggerMock = mock(Logger.class); // WHEN field("notificationService.logger").ofType(Logger.class).in(businessService).set(loggerMock); // THEN assertSame(businessService.getNotificationService().getLogger(), loggerMock); } @Test public void shouldThrowExceptionBecauseOfWrongOrder() { expectedException.expect(ReflectionError.class); expectedException.expectMessage(JUnitMatchers.containsString(// "Unable to find field 'clientStatusDao' in org.fest.reflect.field.NestedFieldTest$BusinessService")); // GIVEN BusinessService businessService = new BusinessService(); Session sessionMock = mock(Session.class); field("clientStatusDao.notificationService.session").ofType(Session.class).in(businessService).set(sessionMock); // WHEN businessService.doLogic(); // THEN verify(sessionMock, times(1)).manageSession(); } @Test public void shouldSetSecondLevelNestedSessionField() { // GIVEN BusinessService businessService = new BusinessService(); Session sessionMock = mock(Session.class); field("notificationService.clientStatusDao.session").ofType(Session.class).in(businessService).set(sessionMock); // WHEN businessService.doLogic(); // THEN verify(sessionMock, times(1)).manageSession(); } @Test public void shouldGetSecondLevelNestedListOfNamesField() { // GIVEN BusinessService businessService = new BusinessService(); // WHEN List listOfNames = field("notificationService.clientStatusDao.listOfNames").ofType(new TypeRef>() {}) .in(businessService).get(); // THEN Assert.assertThat(listOfNames, JUnitMatchers.hasItems("Ivan", "Joel", "Alex")); } @Test public void shouldSetThirdLevelNestedSessionFactoryField() { // GIVEN BusinessService businessService = new BusinessService(); SessionMonitor sessionMonitorMock = mock(SessionMonitor.class); field("notificationService.clientStatusDao.session.sessionMonitor").ofType(SessionMonitor.class)// .in(businessService).set(sessionMonitorMock); // WHEN businessService.doLogic(); // THEN verify(sessionMonitorMock, times(1)).monitor(); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/decorator/000077500000000000000000000000001211245343200273665ustar00rootroot00000000000000TestRuntimeExceptionShield.java000066400000000000000000000051671211245343200354560ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/field/decorator/* * Created on Mar 19, 2012 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2006-2009 the original author or authors. */ package org.fest.reflect.field.decorator; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.lang.reflect.Proxy; import org.junit.Rule; import org.junit.Test; import org.junit.matchers.JUnitMatchers; import org.junit.rules.ExpectedException; /** * @author Ivan Hristov * */ public class TestRuntimeExceptionShield { @Rule public ExpectedException expectedException = ExpectedException.none(); interface ITestService { boolean test() throws IllegalAccessError; } @Test public void shouldShieldFromRuntimeException() { // GIVEN ITestService testServiceMock = mock(ITestService.class); when(testServiceMock.test()).thenThrow(new RuntimeException("Expected test exception")); RuntimeExceptionShield runtimeExceptionShield = new RuntimeExceptionShield(testServiceMock, RuntimeException.class); ITestService proxyObject = (ITestService) Proxy.newProxyInstance(testServiceMock.getClass().getClassLoader(),// new Class[] { ITestService.class }, runtimeExceptionShield); // WHEN proxyObject.test(); // THEN no exception should happen verify(testServiceMock, times(1)).test(); } @Test public void shouldNotShieldFromNonRuntimeException() { // GIVEN expectedException.expect(IllegalAccessError.class); expectedException.expectMessage(JUnitMatchers.containsString("Expected test error")); ITestService testServiceMock = mock(ITestService.class); when(testServiceMock.test()).thenThrow(new IllegalAccessError("Expected test error")); RuntimeExceptionShield runtimeExceptionShield = new RuntimeExceptionShield(testServiceMock, RuntimeException.class); ITestService proxyObject = (ITestService) Proxy.newProxyInstance(testServiceMock.getClass().getClassLoader(),// new Class[] { ITestService.class }, runtimeExceptionShield); // WHEN proxyObject.test(); // THEN there should be an error } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/innerclass/000077500000000000000000000000001211245343200264625ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/innerclass/OuterClass.java000066400000000000000000000021401211245343200314060ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.innerclass; /** * Understands SOMETHING DUMMY. * * @author Alex Ruiz */ public class OuterClass { public static class PublicInnerClass {} protected static class ProtectedInnerClass {} static class PackageInnerClass {} @SuppressWarnings("unused") private static class PrivateInnerClass { private final String name; PrivateInnerClass(String name) { this.name = name; } String name() { return name; } } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/innerclass/StaticInnerClass_Test.java000066400000000000000000000063601211245343200335420ustar00rootroot00000000000000/* * Created on Jan 25, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.innerclass; import static org.fest.reflect.core.Reflection.constructor; import static org.fest.reflect.core.Reflection.field; import static org.fest.reflect.core.Reflection.method; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for inner classes. * * @author Alex Ruiz */ public class StaticInnerClass_Test { @Test public void should_throw_error_if_static_inner_class_name_is_null() { expectNullPointerException("The name of the static inner class to access should not be null").on(new CodeToTest() { public void run() { StaticInnerClassName.startStaticInnerClassAccess(null); } }); } @Test public void should_throw_error_if_static_inner_class_name_is_empty() { expectIllegalArgumentException("The name of the static inner class to access should not be empty").on(new CodeToTest() { public void run() { StaticInnerClassName.startStaticInnerClassAccess(""); } }); } @Test public void should_throw_error_if_declaring_class_is_null() { expectNullPointerException("The declaring class should not be null").on(new CodeToTest() { public void run() { StaticInnerClassName.startStaticInnerClassAccess("Hello").in(null); } }); } @Test public void should_see_static_inner_class() { Class innerClass = StaticInnerClassName.startStaticInnerClassAccess("PrivateInnerClass").in(OuterClass.class).get(); assertTrue(innerClass.getName().contains("PrivateInnerClass")); // make sure we really got the inner classes by creating a new instance and accessing its fields and methods. Object leia = constructor().withParameterTypes(String.class).in(innerClass).newInstance("Leia"); assertEquals("Leia", field("name").ofType(String.class).in(leia).get()); assertEquals("Leia", method("name").withReturnType(String.class).in(leia).invoke()); } @Test public void should_return_null_if_static_inner_class_does_not_exist() { String msg = "The static inner class cannot be found in org.fest.reflect.innerclass.OuterClass"; expectReflectionError(msg).on(new CodeToTest() { public void run() { StaticInnerClassName.startStaticInnerClassAccess("SomeInnerClass").in(OuterClass.class).get(); } }); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/method/000077500000000000000000000000001211245343200256015ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/method/Method_method_Test.java000066400000000000000000000157471211245343200322410ustar00rootroot00000000000000/* * Created on May 18, 2007 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2007-2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.List; import org.junit.Before; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.exception.ReflectionError; import org.fest.reflect.reference.TypeRef; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for accessing methods. * * @author Yvonne Wang * @author Alex Ruiz */ public class Method_method_Test { private Jedi jedi; @Before public void setUp() { jedi = new Jedi("Luke"); } @Test public void should_throw_error_if_method_name_is_null() { expectNullPointerException("The name of the method to access should not be null").on(new CodeToTest() { public void run() { MethodName.startMethodAccess(null); } }); } @Test public void should_throw_error_if_method_name_is_empty() { expectIllegalArgumentException("The name of the method to access should not be empty").on(new CodeToTest() { public void run() { MethodName.startMethodAccess(""); } }); } @Test public void should_throw_error_if_method_return_type_is_null() { String msg = "The return type of the method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { MethodName.startMethodAccess("setName").withReturnType((Class) null); } }); } @Test public void should_throw_error_if_method_return_TypeRef_is_null() { String msg = "The return type reference of the method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { MethodName.startMethodAccess("setName").withReturnType((TypeRef) null); } }); } @Test public void should_throw_error_if_method_parameter_array_is_null() { String msg = "The array of parameter types for the method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { Class[] parameterTypes = null; MethodName.startMethodAccess("setName").withParameterTypes(parameterTypes); } }); } @Test public void should_throw_error_if_method_target_is_null() { expectNullPointerException("Target should not be null").on(new CodeToTest() { public void run() { MethodName.startMethodAccess("setName").in(null); } }); } @Test public void should_call_method_with_args_and_no_return_value() { MethodName.startMethodAccess("setName").withParameterTypes(String.class).in(jedi).invoke("Leia"); assertEquals("Leia", jedi.getName()); } @Test public void should_call_method_with_no_args_and_return_value() { String personName = MethodName.startMethodAccess("getName").withReturnType(String.class).in(jedi).invoke(); assertEquals("Luke", personName); } @Test public void should_call_method_with_args_and_return_value() { jedi.addPower("healing"); String power = MethodName.startMethodAccess("powerAt").withReturnType(String.class).withParameterTypes(int.class).in(jedi) .invoke(0); assertEquals("healing", power); } @Test public void should_call_method_with_no_args_and_return_TypeRef() { jedi.addPower("jump"); List powers = MethodName.startMethodAccess("powers").withReturnType(new TypeRef>() {}).in(jedi).invoke(); assertEquals(1, powers.size()); assertEquals("jump", powers.get(0)); } @Test public void should_call_method_with_args_and_return_TypeRef() { jedi.addPower("healing"); jedi.addPower("jump"); String method = "powersThatStartWith"; List powers = MethodName.startMethodAccess(method).withReturnType(new TypeRef>() {}) .withParameterTypes(String.class).in(jedi).invoke("ju"); assertEquals(1, powers.size()); assertEquals("jump", powers.get(0)); } @Test public void should_call_method_with_no_args_and_no_return_value() { assertFalse(jedi.isMaster()); MethodName.startMethodAccess("makeMaster").in(jedi).invoke(); assertTrue(jedi.isMaster()); } @Test public void should_return_real_method() { java.lang.reflect.Method method = MethodName.startMethodAccess("setName").withParameterTypes(String.class).in(jedi).info(); assertNotNull(method); assertEquals("setName", method.getName()); Class[] parameterTypes = method.getParameterTypes(); assertEquals(1, parameterTypes.length); assertEquals(String.class, parameterTypes[0]); } @Test public void should_throw_error_if_method_name_is_invalid() { String message = "Unable to find method 'getAge' in org.fest.reflect.Jedi with parameter type(s) []"; expectReflectionError(message).on(new CodeToTest() { public void run() { String invalidName = "getAge"; MethodName.startMethodAccess(invalidName).withReturnType(Integer.class).in(jedi); } }); } @Test public void should_throw_error_if_args_for_method_are_invalid() { expectIllegalArgumentException("argument type mismatch").on(new CodeToTest() { public void run() { int invalidArg = 8; MethodName.startMethodAccess("setName").withParameterTypes(String.class).in(jedi).invoke(invalidArg); } }); } @Test public void should_rethrow_RuntimeException_thrown_by_method() { try { MethodName.startMethodAccess("throwRuntimeException").in(jedi).invoke(); fail("Expecting an IllegalStateException"); } catch (IllegalStateException e) { assertEquals("Somehow I got in an illegal state", e.getMessage()); } } @Test public void should_wrap_with_a_ReflectionError_the_checked_Exception_thrown_by_method() { try { MethodName.startMethodAccess("throwCheckedException").in(jedi).invoke(); fail("Expecting an ReflectionError"); } catch (ReflectionError e) { Throwable cause = e.getCause(); assertTrue(cause instanceof Exception); assertEquals("I don't know what's wrong", cause.getMessage()); } } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/method/Method_staticMethod_Test.java000066400000000000000000000142531211245343200334000ustar00rootroot00000000000000/* * Created on Nov 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.method; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.fest.reflect.util.ExpectedFailures.expectReflectionError; import static org.junit.Assert.assertEquals; import java.util.List; import org.junit.Before; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.reference.TypeRef; import org.fest.test.CodeToTest; /** * Tests for the fluent interface for accessing static methods. * * @author Yvonne Wang * @author Alex Ruiz */ public class Method_staticMethod_Test { @Before public void setUp() { Jedi.clearCommonPowers(); } @Test public void should_throw_error_if_static_method_name_is_null() { expectNullPointerException("The name of the static method to access should not be null").on(new CodeToTest() { public void run() { StaticMethodName.startStaticMethodAccess(null); } }); } @Test public void should_throw_error_if_static_method_name_is_empty() { expectIllegalArgumentException("The name of the static method to access should not be empty").on(new CodeToTest() { public void run() { StaticMethodName.startStaticMethodAccess(""); } }); } @Test public void should_throw_error_if_static_method_return_type_is_null() { String msg = "The return type of the static method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { StaticMethodName.startStaticMethodAccess("commonPowerCount").withReturnType((Class) null); } }); } @Test public void should_throw_error_if_static_method_return_TypeRef_is_null() { String msg = "The return type reference of the static method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { StaticMethodName.startStaticMethodAccess("commonPowerCount").withReturnType((TypeRef) null); } }); } @Test public void should_throw_error_if_static_method_parameter_array_is_null() { String msg = "The array of parameter types for the static method to access should not be null"; expectNullPointerException(msg).on(new CodeToTest() { public void run() { Class[] parameterTypes = null; StaticMethodName.startStaticMethodAccess("commonPowerCount").withParameterTypes(parameterTypes); } }); } @Test public void should_throw_error_if_static_method_target_is_null() { expectNullPointerException("Target should not be null").on(new CodeToTest() { public void run() { StaticMethodName.startStaticMethodAccess("commonPowerCount").in(null); } }); } @Test public void should_call_static_method_with_no_args_and_return_value() { Jedi.addCommonPower("Jump"); int count = StaticMethodName.startStaticMethodAccess("commonPowerCount").withReturnType(int.class).in(Jedi.class).invoke(); assertEquals(Jedi.commonPowerCount(), count); } @Test public void should_call_static_method_with_args_and_return_value() { Jedi.addCommonPower("Jump"); String power = StaticMethodName.startStaticMethodAccess("commonPowerAt").withReturnType(String.class) .withParameterTypes(int.class).in(Jedi.class).invoke(0); assertEquals("Jump", power); } @Test public void should_call_static_method_with_no_args_and_return_TypeRef() { Jedi.addCommonPower("jump"); String method = "commonPowers"; List powers = StaticMethodName.startStaticMethodAccess(method).withReturnType(new TypeRef>() {}) .in(Jedi.class).invoke(); assertEquals(1, powers.size()); assertEquals("jump", powers.get(0)); } @Test public void should_call_static_method_with_args_and_return_TypeRef() { Jedi.addCommonPower("jump"); String method = "commonPowersThatStartWith"; List powers = StaticMethodName.startStaticMethodAccess(method).withReturnType(new TypeRef>() {}) .withParameterTypes(String.class).in(Jedi.class).invoke("ju"); assertEquals(1, powers.size()); assertEquals("jump", powers.get(0)); } @Test public void should_call_static_method_with_args_and_no_return_value() { StaticMethodName.startStaticMethodAccess("addCommonPower").withParameterTypes(String.class).in(Jedi.class).invoke("Jump"); assertEquals("Jump", Jedi.commonPowerAt(0)); } @Test public void should_call_static_method_with_no_args_and_no_return_value() { Jedi.addCommonPower("Jump"); assertEquals(1, Jedi.commonPowerCount()); assertEquals("Jump", Jedi.commonPowerAt(0)); StaticMethodName.startStaticMethodAccess("clearCommonPowers").in(Jedi.class).invoke(); assertEquals(0, Jedi.commonPowerCount()); } @Test public void should_throw_error_if_static_method_name_is_invalid() { String message = "Unable to find method 'powerSize' in org.fest.reflect.Jedi with parameter type(s) []"; expectReflectionError(message).on(new CodeToTest() { public void run() { String invalidName = "powerSize"; StaticMethodName.startStaticMethodAccess(invalidName).in(Jedi.class); } }); } @Test public void should_throw_error_if_args_for_static_method_are_invalid() { expectIllegalArgumentException("argument type mismatch").on(new CodeToTest() { public void run() { int invalidArg = 8; StaticMethodName.startStaticMethodAccess("addCommonPower").withParameterTypes(String.class).in(Jedi.class) .invoke(invalidArg); } }); } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/type/000077500000000000000000000000001211245343200253025ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/type/Type_Test.java000066400000000000000000000076021211245343200300720ustar00rootroot00000000000000/* * Created on Jan 23, 2009 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2009 the original author or authors. */ package org.fest.reflect.type; import static org.fest.reflect.util.ExpectedFailures.expectIllegalArgumentException; import static org.fest.reflect.util.ExpectedFailures.expectNullPointerException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.junit.Test; import org.fest.reflect.Jedi; import org.fest.reflect.Person; import org.fest.reflect.exception.ReflectionError; import org.fest.test.CodeToTest; /** * Tests for {@link Type}. * * @author Alex Ruiz */ public class Type_Test { @Test public void should_throw_error_if__type_name_is_null() { expectNullPointerException("The name of the class to load should not be null").on(new CodeToTest() { public void run() { Type.newType(null); } }); } @Test public void should_throw_error_if__type_name_is_empty() { expectIllegalArgumentException("The name of the class to load should not be empty").on(new CodeToTest() { public void run() { Type.newType(""); } }); } @Test public void should_throw_error_if_subtype_is_mull() { expectNullPointerException("The given type should not be null").on(new CodeToTest() { public void run() { Type.newType("hello").loadAs(null); } }); } @Test public void should_load_class() { Class expected = Jedi.class; Class type = Type.newType(expected.getName()).load(); assertEquals(expected, type); } @Test public void should_load_class_with_given_ClassLoader() { Class expected = Jedi.class; Class type = Type.newType(expected.getName()).withClassLoader(getClass().getClassLoader()).load(); assertEquals(expected, type); } @Test public void should_throw_error_if_Classloader_is_null() { expectNullPointerException("The given class loader should not be null").on(new CodeToTest() { public void run() { Type.newType("hello").withClassLoader(null); } }); } @Test public void should_wrap_any_Exception_thrown_when_loading_class() { try { Type.newType("org.fest.reflect.NonExistingType").load(); } catch (ReflectionError expected) { assertTrue(expected.getMessage().contains("Unable to load class 'org.fest.reflect.NonExistingType' using class loader ")); assertTrue(expected.getCause() instanceof ClassNotFoundException); } } @Test public void should_load_class_as_given_type() { Class type = Type.newType(Jedi.class.getName()).loadAs(Person.class); assertEquals(Jedi.class, type); } @Test public void should_load_class_as_given_type_with_given_ClassLoader() { Class type = Type.newType(Jedi.class.getName()).withClassLoader(getClass().getClassLoader()) .loadAs(Person.class); assertEquals(Jedi.class, type); } @Test public void should_wrap_any_Exception_thrown_when_loading_class_as_given_type() { try { Type.newType("org.fest.reflect.NonExistingType").loadAs(Jedi.class); } catch (ReflectionError expected) { assertTrue(expected.getMessage().contains( "Unable to load class 'org.fest.reflect.NonExistingType' as org.fest.reflect.Jedi using class loader ")); assertTrue(expected.getCause() instanceof ClassNotFoundException); } } } fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/util/000077500000000000000000000000001211245343200252765ustar00rootroot00000000000000fest-reflect-fest-reflect-1.4.1/src/test/java/org/fest/reflect/util/ExpectedFailures.java000066400000000000000000000025551211245343200314040ustar00rootroot00000000000000/* * Created on Feb 18, 2008 * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. * * Copyright @2008-2009 the original author or authors. */ package org.fest.reflect.util; import org.fest.reflect.exception.ReflectionError; import org.fest.test.ExpectedFailure.Message; import static org.fest.test.ExpectedFailure.expect; /** * Understands expected failures. * * @author Alex Ruiz */ public final class ExpectedFailures { public static Message expectReflectionError(String message) { return expect(ReflectionError.class).withMessage(message); } public static Message expectIllegalArgumentException(String message) { return expect(IllegalArgumentException.class).withMessage(message); } public static Message expectNullPointerException(String message) { return expect(NullPointerException.class).withMessage(message); } private ExpectedFailures() {} }