View Javadoc

1   package com.lexicalscope.fluentreflection;
2   
3   /*
4    * Copyright 2011 Tim Wood
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.util.List;
20  
21  import org.hamcrest.Matcher;
22  
23  /**
24   * Reflection information about a class.
25   *
26   * @author tim
27   *
28   * @param <T> the underlying type being reflected on
29   */
30  public interface FluentClass<T> extends FluentAccess<T> {
31      /**
32       * True iff the type is an interface
33       *
34       * @return True iff the type is an interface
35       */
36      boolean isInterface();
37  
38      /**
39       * Get this type as the first matching the supplied matcher. This type and
40       * then the supertypes are searched
41       *
42       * @param typeMatcher
43       *            matcher on the required type
44       *
45       * @return first matching the matcher
46       */
47      FluentClass<?> asType(Matcher<FluentClass<?>> typeMatcher);
48  
49      /**
50       * Construct an object of the type under reflection
51       *
52       * @return the constructed object
53       */
54      T constructRaw(Object... args);
55  
56      /**
57       * Construct an object of the type under reflection
58       *
59       * @return a reflection wrapper around the constructed object
60       */
61      FluentObject<T> construct(Object... args);
62  
63      /**
64       * Find all constructors matching the supplied matcher
65       *
66       * @param constructorMatcher
67       *            matches the constructors
68       *
69       * @return all constructors matching the supplied matcher
70       */
71      List<FluentConstructor<T>> constructors(Matcher<? super FluentConstructor<?>> constructorMatcher);
72  
73      /**
74       * Find the first constructor method matching the supplied matcher
75       *
76       * @param constructorMatcher
77       *            matches the method
78       *
79       * @return The constructor matching the supplied matcher
80       */
81      FluentConstructor<T> constructor(Matcher<? super FluentConstructor<?>> constructorMatcher);
82  
83      /**
84       * Find the first static method matching the supplied matcher
85       *
86       * @param methodNamed
87       *            matches the method
88       *
89       * @return The method matching the supplied matcher
90       */
91      FluentMethod staticMethod(Matcher<? super FluentMethod> methodNamed);
92  }