01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.reflect;
08:
09: /**
10: * Inspects info.
11: *
12: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
13: */
14: public class MetaDataInspector {
15: /**
16: * Checks if a class has a certain field.
17: *
18: * @param classInfo
19: * @param fieldName
20: * @return
21: */
22: public static boolean hasField(final ClassInfo classInfo,
23: final String fieldName) {
24: for (int i = 0; i < classInfo.getFields().length; i++) {
25: FieldInfo fieldMetaData = classInfo.getFields()[i];
26: if (fieldMetaData.getName().equals(fieldName)) {
27: return true;
28: }
29: }
30: return false;
31: }
32:
33: /**
34: * Checks if a class implements a certain interface.
35: *
36: * @param classInfo
37: * @param interfaceName
38: * @return
39: */
40: public static boolean hasInterface(final ClassInfo classInfo,
41: final String interfaceName) {
42: for (int i = 0; i < classInfo.getInterfaces().length; i++) {
43: ClassInfo interfaceMetaData = classInfo.getInterfaces()[i];
44: if (interfaceMetaData.getName().equals(interfaceName)) {
45: return true;
46: }
47: }
48: return false;
49: }
50: }
|