List of usage examples for java.lang.reflect ParameterizedType getActualTypeArguments
Type[] getActualTypeArguments();
From source file:com.facebook.GraphObjectWrapper.java
static <U> U coerceValueToExpectedType(Object value, Class<U> expectedType, ParameterizedType expectedTypeAsParameterizedType) { if (value == null) { return null; }/*from w w w . j av a 2s . c o m*/ Class<?> valueType = value.getClass(); if (expectedType.isAssignableFrom(valueType)) { @SuppressWarnings("unchecked") U result = (U) value; return result; } if (expectedType.isPrimitive()) { // If the result is a primitive, let the runtime succeed or fail at unboxing it. @SuppressWarnings("unchecked") U result = (U) value; return result; } if (GraphObject.class.isAssignableFrom(expectedType)) { @SuppressWarnings("unchecked") Class<? extends GraphObject> graphObjectClass = (Class<? extends GraphObject>) expectedType; // We need a GraphObject, but we don't have one. if (JSONObject.class.isAssignableFrom(valueType)) { // We can wrap a JSONObject as a GraphObject. @SuppressWarnings("unchecked") U result = (U) createGraphObjectProxy(graphObjectClass, (JSONObject) value); return result; } else if (GraphObject.class.isAssignableFrom(valueType)) { // We can cast a GraphObject-derived class to another GraphObject-derived class. @SuppressWarnings("unchecked") U result = (U) ((GraphObject) value).cast(graphObjectClass); return result; } else { throw new FacebookGraphObjectException("Can't create GraphObject from " + valueType.getName()); } } else if (Iterable.class.equals(expectedType) || Collection.class.equals(expectedType) || List.class.equals(expectedType) || GraphObjectList.class.equals(expectedType)) { if (expectedTypeAsParameterizedType == null) { throw new FacebookGraphObjectException("can't infer generic type of: " + expectedType.toString()); } Type[] actualTypeArguments = expectedTypeAsParameterizedType.getActualTypeArguments(); if (actualTypeArguments == null || actualTypeArguments.length != 1 || !(actualTypeArguments[0] instanceof Class<?>)) { throw new FacebookGraphObjectException( "Expect collection properties to be of a type with exactly one generic parameter."); } Class<?> collectionGenericArgument = (Class<?>) actualTypeArguments[0]; if (JSONArray.class.isAssignableFrom(valueType)) { JSONArray jsonArray = (JSONArray) value; @SuppressWarnings("unchecked") U result = (U) wrapArray(jsonArray, collectionGenericArgument); return result; } else { throw new FacebookGraphObjectException("Can't create Collection from " + valueType.getName()); } } else if (String.class.equals(expectedType)) { if (Number.class.isAssignableFrom(valueType)) { @SuppressWarnings("unchecked") U result = (U) String.format("%d", value); return result; } } else if (Date.class.equals(expectedType)) { if (String.class.isAssignableFrom(valueType)) { for (SimpleDateFormat format : dateFormats) { try { Date date = format.parse((String) value); if (date != null) { @SuppressWarnings("unchecked") U result = (U) date; return result; } } catch (ParseException e) { // Keep going. } } } } throw new FacebookGraphObjectException( "Can't convert type" + valueType.getName() + " to " + expectedType.getName()); }
From source file:org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.java
protected Method[] processMethods(Method[] declaredMethods) throws Exception { ArrayList<Method> list = new ArrayList<Method>(); //short the elements in the array Arrays.sort(declaredMethods, new MathodComparator()); // since we do not support overload HashMap<String, Method> uniqueMethods = new LinkedHashMap<String, Method>(); XmlSchemaComplexType methodSchemaType; XmlSchemaSequence sequence = null;/*from ww w. j a va2 s . c om*/ for (Method jMethod : declaredMethods) { if (jMethod.isBridge()) { continue; } WebMethodAnnotation methodAnnon = JSR181Helper.INSTANCE.getWebMethodAnnotation(jMethod); String methodName = jMethod.getName(); if (methodAnnon != null) { if (methodAnnon.isExclude()) { continue; } if (methodAnnon.getOperationName() != null) { methodName = methodAnnon.getOperationName(); } } // no need to think abt this method , since that is system // config method if (excludeMethods.contains(methodName)) { continue; } if (!Modifier.isPublic(jMethod.getModifiers())) { // no need to generate Schema for non public methods continue; } if (uniqueMethods.get(methodName) != null) { log.warn("We don't support method overloading. Ignoring [" + methodName + "]"); continue; } boolean addToService = false; AxisOperation axisOperation = service.getOperation(new QName(methodName)); if (axisOperation == null) { axisOperation = Utils.getAxisOperationForJmethod(jMethod); // if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals( // axisOperation.getMessageExchangePattern())) { // AxisMessage outMessage = axisOperation.getMessage( // WSDLConstants.MESSAGE_LABEL_OUT_VALUE); // if (outMessage != null) { // outMessage.setName(methodName + RESPONSE); // } // } addToService = true; } // by now axis operation should be assigned but we better recheck & add the paramether if (axisOperation != null) { axisOperation.addParameter("JAXRSAnnotaion", JAXRSUtils.getMethodModel(this.classModel, jMethod)); } // Maintain a list of methods we actually work with list.add(jMethod); processException(jMethod, axisOperation); uniqueMethods.put(methodName, jMethod); Class<?>[] parameters = jMethod.getParameterTypes(); String parameterNames[] = null; AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (inMessage != null) { inMessage.setName(methodName + Java2WSDLConstants.MESSAGE_SUFFIX); } if (parameters.length > 0) { parameterNames = methodTable.getParameterNames(methodName); // put the parameter names to use it for parsing service.addParameter(methodName, parameterNames); } // we need to add the method opration wrapper part even to // empty parameter operations sequence = new XmlSchemaSequence(); String requestElementSuffix = getRequestElementSuffix(); String requestLocalPart = methodName; if (requestElementSuffix != null) { requestLocalPart += requestElementSuffix; } methodSchemaType = createSchemaTypeForMethodPart(requestLocalPart); methodSchemaType.setParticle(sequence); inMessage.setElementQName(typeTable.getQNamefortheType(requestLocalPart)); Parameter param = service.getParameter(Java2WSDLConstants.MESSAGE_PART_NAME_OPTION_LONG); if (param != null) { inMessage.setPartName((String) param.getValue()); } service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(), axisOperation); Annotation[][] parameterAnnotation = jMethod.getParameterAnnotations(); Type[] genericParameterTypes = jMethod.getGenericParameterTypes(); for (int j = 0; j < parameters.length; j++) { Class<?> methodParameter = parameters[j]; String parameterName = getParameterName(parameterAnnotation, j, parameterNames); if (nonRpcMethods.contains(jMethod.getName())) { generateSchemaForType(sequence, null, jMethod.getName()); break; } else { Type genericParameterType = genericParameterTypes[j]; Type genericType = null; if (genericParameterType instanceof ParameterizedType) { ParameterizedType aType = (ParameterizedType) genericParameterType; Type[] parameterArgTypes = aType.getActualTypeArguments(); genericType = parameterArgTypes[0]; generateSchemaForType(sequence, genericType, parameterName, true); } else { generateSchemaForType(sequence, methodParameter, parameterName); } } } // for its return type Class<?> returnType = jMethod.getReturnType(); if (!"void".equals(jMethod.getReturnType().getName())) { String partQname = methodName + RESPONSE; methodSchemaType = createSchemaTypeForMethodPart(partQname); sequence = new XmlSchemaSequence(); methodSchemaType.setParticle(sequence); WebResultAnnotation returnAnnon = JSR181Helper.INSTANCE.getWebResultAnnotation(jMethod); String returnName = "return"; if (returnAnnon != null) { returnName = returnAnnon.getName(); if (returnName == null || "".equals(returnName)) { returnName = "return"; } } Type genericParameterType = jMethod.getGenericReturnType(); if (nonRpcMethods.contains(jMethod.getName())) { generateSchemaForType(sequence, null, returnName); } else if (genericParameterType instanceof ParameterizedType) { ParameterizedType aType = (ParameterizedType) genericParameterType; Type[] parameterArgTypes = aType.getActualTypeArguments(); generateSchemaForType(sequence, parameterArgTypes[0], returnName, true); } else { generateSchemaForType(sequence, returnType, returnName); } AxisMessage outMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); outMessage.setElementQName(typeTable.getQNamefortheType(partQname)); outMessage.setName(partQname); Parameter outparam = service.getParameter(Java2WSDLConstants.MESSAGE_PART_NAME_OPTION_LONG); if (outparam != null) { outMessage.setPartName((String) outparam.getValue()); } service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(), axisOperation); } if (addToService) { service.addOperation(axisOperation); } } return list.toArray(new Method[list.size()]); }
From source file:com.github.helenusdriver.driver.impl.FieldInfoImpl.java
/** * Instantiates a new <code>FieldInfo</code> object as a column part of a * defined table.//ww w .j av a 2s . co m * * @author vasu * * @param tinfo the table info for the field * @param field the non-<code>null</code> field to create an info object for * @throws IllegalArgumentException if unable to find a getter or setter * method for the field of if improperly annotated */ FieldInfoImpl(TableInfoImpl<T> tinfo, Field field) { this.clazz = tinfo.getObjectClass(); this.cinfo = (ClassInfoImpl<T>) tinfo.getClassInfo(); this.tinfo = tinfo; this.declaringClass = field.getDeclaringClass(); this.field = field; field.setAccessible(true); // make it accessible in case we need to this.isFinal = Modifier.isFinal(field.getModifiers()); this.name = field.getName(); this.type = DataTypeImpl.unwrapOptionalIfPresent(field.getType(), field.getGenericType()); this.persisted = field.getAnnotation(Persisted.class); if (persisted != null) { org.apache.commons.lang3.Validate.isTrue( (persisted.as() != DataType.INFERRED) && !persisted.as().isCollection(), "@Persisted annotation cannot be of type '%s': %s.%s", persisted.as(), declaringClass.getName(), field.getName()); this.persister = newPersister(); } else { this.persister = null; } this.suffix = field.getAnnotation(SuffixKey.class); this.mandatory = field.getAnnotation(Mandatory.class) != null; final Map<String, Column> columns = ReflectionUtils.getAnnotationsByType(String.class, Column.class, field); final Map<String, Index> indexes = ReflectionUtils.getAnnotationsByType(String.class, Index.class, field); final Map<String, PartitionKey> partitionKeys = ReflectionUtils.getAnnotationsByType(String.class, PartitionKey.class, field); final Map<String, ClusteringKey> clusteringKeys = ReflectionUtils.getAnnotationsByType(String.class, ClusteringKey.class, field); final Map<String, TypeKey> typeKeys = ReflectionUtils.getAnnotationsByType(String.class, TypeKey.class, field); final boolean isInTable = tinfo.getTable() != null; if (isInTable) { org.apache.commons.lang3.Validate.isTrue(!(!indexes.isEmpty() && columns.isEmpty()), "field must be annotated with @Column if it is annotated with @Index: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(!partitionKeys.isEmpty() && columns.isEmpty()), "field must be annotated with @Column if it is annotated with @PartitionKey: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(!clusteringKeys.isEmpty() && columns.isEmpty()), "field must be annotated with @Column if it is annotated with @ClusteringKey: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(!typeKeys.isEmpty() && columns.isEmpty()), "field must be annotated with @Column if it is annotated with @TypeKey: %s.%s", declaringClass.getName(), field.getName()); } // Note: while searching for the matching table, uses the name from the // table annotation instead of the one returned by getName() as the later // might have been cleaned and hence would not match what was defined in // the POJO final String tname = isInTable ? tinfo.getTable().name() : Table.ALL; Column column = columns.get(tname); Index index = indexes.get(tname); PartitionKey partitionKey = partitionKeys.get(tname); ClusteringKey clusteringKey = clusteringKeys.get(tname); TypeKey typeKey = typeKeys.get(tname); if (column == null) { // fallback to special Table.ALL name column = columns.get(Table.ALL); } this.column = column; if (index == null) { // fallback to special Table.ALL name index = indexes.get(Table.ALL); } this.index = index; if (partitionKey == null) { // fallback to special Table.ALL name partitionKey = partitionKeys.get(Table.ALL); } this.partitionKey = partitionKey; if (clusteringKey == null) { // fallback to special Table.ALL name clusteringKey = clusteringKeys.get(Table.ALL); } this.clusteringKey = clusteringKey; if (typeKey == null) { // fallback to special Table.ALL name typeKey = typeKeys.get(Table.ALL); } this.typeKey = typeKey; // validate some UDT stuff if (!isInTable) { org.apache.commons.lang3.Validate.isTrue(!isIndex(), "field cannot be annotated with @Index: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!isPartitionKey(), "field cannot be annotated with @PartitionKey: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!isClusteringKey(), "field cannot be annotated with @ClusteringKey: %s.%s", declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!isTypeKey(), "field cannot be annotated with @TypeKey: %s.%s", declaringClass.getName(), field.getName()); } if (isColumn()) { this.definition = DataTypeImpl.inferDataTypeFrom(field); this.decoder = definition.getDecoder(field, isMandatory() || isPartitionKey() || isClusteringKey()); if (isInTable && ((clusteringKey != null) || (partitionKey != null)) && (definition.getType() == DataType.SET)) { final Type type = field.getGenericType(); if (type instanceof ParameterizedType) { final ParameterizedType ptype = (ParameterizedType) type; this.multiKeyType = ReflectionUtils.getRawClass(ptype.getActualTypeArguments()[0]); // sets will always have 1 argument } else { throw new IllegalArgumentException( "unable to determine the element type of multi-field in table '" + tname + "': " + declaringClass.getName() + "." + field.getName()); } } else { this.multiKeyType = null; } } else { this.definition = null; this.decoder = null; this.multiKeyType = null; } this.getter = findGetterMethod(declaringClass); this.setter = findSetterMethod(declaringClass); this.finalValue = findFinalValue(); // validate some stuff if (isInTable) { org.apache.commons.lang3.Validate.isTrue(!(isIndex() && !isColumn()), "field in table '%s' must be annotated with @Column if it is annotated with @Index: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isPartitionKey() && isClusteringKey()), "field in table '%s' must not be annotated with @ClusteringKey if it is annotated with @PartitionKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isPartitionKey() && !isColumn()), "field in table '%s' must be annotated with @Column if it is annotated with @PartitionKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isClusteringKey() && !isColumn()), "field in table '%s' must be annotated with @Column if it is annotated with @ClusteringKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isTypeKey() && !isColumn()), "field in table '%s' must be annotated with @Column if it is annotated with @TypeKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isTypeKey() && !String.class.equals(getType())), "field in table '%s' must be a String if it is annotated with @TypeKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue(!(isTypeKey() && isFinal()), "field in table '%s' must not be final if it is annotated with @TypeKey: %s.%s", tname, declaringClass.getName(), field.getName()); org.apache.commons.lang3.Validate.isTrue( !(isTypeKey() && !(cinfo instanceof RootClassInfoImpl) && !(cinfo instanceof TypeClassInfoImpl)), "field in table '%s' must not be annotated with @TypeKey if class is annotated with @Entity: %s.%s", tname, declaringClass.getName(), field.getName()); if (isColumn() && definition.isCollection()) { org.apache.commons.lang3.Validate.isTrue( !((isClusteringKey() || isPartitionKey()) && (multiKeyType == null)), "field in table '%s' cannot be '%s' if it is annotated with @ClusteringKey or @PartitionKey: %s.%s", tname, definition, declaringClass.getName(), field.getName()); } } }
From source file:org.soybeanMilk.core.bean.DefaultGenericConverter.java
/** * ?/* ww w. ja v a 2 s . co m*/ * @param map * @param type * @return * @throws ConvertException * @date 2012-5-14 */ @SuppressWarnings("unchecked") protected Object convertMapToType(Map<?, ?> map, Type type) throws ConvertException { Object result = null; // Type customType = getMapCustomTargetType(map, null); if (customType != null) type = customType; if (type == null) { result = map; } else if (SbmUtils.isClassType(type)) { Class<?> clazz = SbmUtils.narrowToClass(type); //Map??? if (customType == null && isAncestorType(Map.class, clazz)) { result = map; } else { result = convertPropertyValueMapToClass(toPropertyValueMap((Map<String, ?>) map), clazz); } } else if (type instanceof ParameterizedType) { boolean convert = true; ParameterizedType pt = (ParameterizedType) type; Type rt = pt.getRawType(); //Map<?, ?>Map<Object, Object>??? if (isAncestorType(rt, map.getClass())) { Type[] at = pt.getActualTypeArguments(); if (at != null && at.length == 2 && ((Object.class.equals(at[0]) && Object.class.equals(at[1])) || (isSimpleWildcardType(at[0]) && isSimpleWildcardType(at[1])))) { convert = false; } } if (convert) result = convertPropertyValueMapToParameterrizedType(toPropertyValueMap((Map<String, ?>) map), pt); else result = map; } else if (type instanceof GenericArrayType) { result = convertPropertyValueMapToGenericArrayType(toPropertyValueMap((Map<String, ?>) map), (GenericArrayType) type); } else if (type instanceof TypeVariable<?>) { result = convertObjectToType(map, reify(type)); } else if (type instanceof WildcardType) { result = convertObjectToType(map, reify(type)); } else result = converterNotFoundThrow(map.getClass(), type); return result; }
From source file:org.evosuite.utils.generic.GenericClass.java
public GenericClass getWithOwnerType(GenericClass ownerClass) { if (type instanceof ParameterizedType) { ParameterizedType currentType = (ParameterizedType) type; return new GenericClass(new ParameterizedTypeImpl(rawClass, currentType.getActualTypeArguments(), ownerClass.getType()));//w ww . j a v a 2s .c o m } return new GenericClass(type); }
From source file:org.nextframework.controller.ExtendedBeanWrapper.java
private Type getPropertyType(PropertyTokenHolder tokens) { String propertyName = tokens.canonicalName; PropertyDescriptor pd = getPropertyDescriptorInternal(tokens.actualName); if (pd == null || pd.getReadMethod() == null) { throw new NotReadablePropertyException(getRootClass(), this.nestedPath + propertyName); }//from ww w . j ava2 s . c om if (logger.isDebugEnabled()) logger.debug("About to invoke read method [" + pd.getReadMethod() + "] on object of class [" + this.object.getClass().getName() + "]"); try { Type type = pd.getReadMethod().getGenericReturnType(); if (tokens.keys != null) { // apply indexes and map keys for (int i = 0; i < tokens.keys.length; i++) { if (type == null) { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + propertyName, "Cannot access indexed value of property referenced in indexed " + "property path '" + propertyName + "': returned null"); } else if (type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) type; Class clazz = (Class) parameterizedType.getRawType(); if (Map.class.isAssignableFrom(clazz)) { type = parameterizedType.getActualTypeArguments()[1]; } else if (Collection.class.isAssignableFrom(clazz)) { type = parameterizedType.getActualTypeArguments()[0]; } else { throw new RuntimeException("Tipo desconhecido " + parameterizedType); } } else if (type instanceof Class && ((Class) type).isArray()) { return type; } else { throw new RuntimeException("Implementar converso!!!"); } } } return type; } catch (IndexOutOfBoundsException ex) { throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName, "Index of out of bounds in property path '" + propertyName + "'", ex); } catch (NumberFormatException ex) { throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName, "Invalid index in property path '" + propertyName + "'", ex); } }
From source file:org.openmrs.module.sync.api.db.hibernate.HibernateSyncInterceptor.java
/** * Checks the collection to see if it is a collection of supported types. If so, then it returns * appropriate normalizer. Note, this handles maps too. * * @param object//w ww . j a va 2 s .c om * @param propertyName * @return a Normalizer for the given type or null if not a safe type * @throws NoSuchFieldException * @throws SecurityException */ private Normalizer isCollectionOfSafeTypes(OpenmrsObject object, String propertyName) throws SecurityException, NoSuchFieldException { try { java.lang.reflect.ParameterizedType collectionType = ((java.lang.reflect.ParameterizedType) object .getClass().getDeclaredField(propertyName).getGenericType()); if (Map.class.isAssignableFrom((Class) collectionType.getRawType())) { //this is a map; Map<K,V>: verify that K and V are of types we know how to process java.lang.reflect.Type keyType = collectionType.getActualTypeArguments()[0]; java.lang.reflect.Type valueType = collectionType.getActualTypeArguments()[1]; Normalizer keyNormalizer = SyncUtil.getNormalizer((Class) keyType); Normalizer valueNormalizer = SyncUtil.getNormalizer((Class) valueType); if (keyNormalizer != null && valueNormalizer != null) { return SyncUtil.getNormalizer((Class) collectionType.getRawType()); } else { return null; } } else { //this is some other collection, so just get a normalizer for its return SyncUtil.getNormalizer((Class) (collectionType.getActualTypeArguments()[0])); } } catch (Throwable t) { // might get here if the property is on a superclass to the object log.trace("Unable to get collection field: " + propertyName + " from object " + object.getClass() + " for some reason", t); } // on errors just return null return null; }
From source file:org.evosuite.utils.generic.GenericClass.java
/** * Serialize, but need to abstract classloader away * // w w w. ja v a 2 s . c o m * @param oos * @throws IOException */ private void writeObject(ObjectOutputStream oos) throws IOException { if (rawClass == null) { oos.writeObject(null); } else { oos.writeObject(rawClass.getName()); if (type instanceof ParameterizedType) { oos.writeObject(Boolean.TRUE); ParameterizedType pt = (ParameterizedType) type; // oos.writeObject(new GenericClass(pt.getRawType())); oos.writeObject(new GenericClass(pt.getOwnerType())); List<GenericClass> parameterClasses = new ArrayList<GenericClass>(); for (Type parameterType : pt.getActualTypeArguments()) { parameterClasses.add(new GenericClass(parameterType)); } oos.writeObject(parameterClasses); } else { oos.writeObject(Boolean.FALSE); } } }
From source file:com.gatf.generator.core.GatfTestGeneratorMojo.java
/** * @param claz// w w w. j a va 2 s .co m * @param parameters * @param naming * @param formpnm * @param isheaderParam * @param heirarchy * @throws Exception Add new ViewFeild objects that represnt the form elements on the test page of the give rest * full service */ @SuppressWarnings("rawtypes") private ViewField getViewField(Type claz) throws Exception { ViewField viewField = null; try { ParameterizedType type = null; Class clas = null; if (claz instanceof ParameterizedType) { type = (ParameterizedType) claz; clas = (Class) type.getRawType(); } else { clas = (Class) claz; } List<Type> heirarchies = new ArrayList<Type>(); if (isPrimitive(clas)) { viewField = new ViewField(); viewField.setClaz(clas); viewField.setValue(getPrimitiveValue(claz)); } else if (isMap(clas)) { viewField = new ViewField(); viewField.setClaz(clas); viewField.setValue(getMapValue(clas, type.getActualTypeArguments(), heirarchies)); } else if (isCollection(clas)) { viewField = new ViewField(); viewField.setClaz(clas); viewField.setValue(getListSetValue(clas, type.getActualTypeArguments(), heirarchies)); } else if (!clas.isInterface()) { viewField = new ViewField(); viewField.setClaz(clas); viewField.setValue(getObject(clas, heirarchies)); } } catch (Exception e) { getLog().error(e); getLog().info( "Invalid class, cannot be represented as a form/object in a test case - class name = " + claz); } return viewField; }