List of usage examples for java.lang Class isPrimitive
@HotSpotIntrinsicCandidate public native boolean isPrimitive();
From source file:com.github.wshackle.java4cpp.J4CppMain.java
public static boolean isAddableClass(Class<?> clss, Set<Class> excludedClasses) { if (clss.isArray() || clss.isSynthetic() || clss.isAnnotation() || clss.isPrimitive()) { return false; }//from w ww . j av a 2s . c o m // if(clss.getCanonicalName().contains("Dialog") || clss.getName().contains("ModalExlusionType")) { // if(verbose) System.out.println("clss = " + clss); // } // if (clss.getEnclosingClass() != null) { // return false; // } String canonicalName = null; try { canonicalName = clss.getCanonicalName(); } catch (Throwable t) { // leaving canonicalName null is enough } if (null == canonicalName) { return false; } if (canonicalName.indexOf('$') >= 0) { return false; } String pkgNames[] = clss.getCanonicalName().split("\\."); for (int i = 0; i < pkgNames.length; i++) { String pkgName = pkgNames[i]; if (badNames.contains(pkgName)) { return false; } } Method ma[] = null; try { ma = clss.getDeclaredMethods(); } catch (Throwable t) { // leaving canonicalName null is enough } if (null == ma) { return false; } return !excludedClasses.contains(clss); }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
private static boolean checkClass(Class<?> clss, List<Class> classes) { Class<?> componentClass = clss.getComponentType(); boolean ret = isString(clss) || clss.equals(Object.class) || clss.isPrimitive() || (clss.isArray() && null != componentClass && !componentClass.isArray() && checkClass(componentClass, classes)) || classes.contains(clss);//from w ww .j a va 2s .co m if (!ret) { if (verbose) { if (clss.isArray()) { System.out.println("checkClass skipping " + clss + " component " + clss.getComponentType()); } else { System.out.println("checkClass skipping " + clss); } } } return ret; }
From source file:net.arnx.jsonic.JSON.java
/** * Converts Map, List, Number, String, Boolean or null to other Java Objects after parsing. * //www . j a va 2s . com * @param context current context. * @param value null or the instance of Map, List, Number, String or Boolean. * @param cls class for converting * @param type generics type for converting. type equals to c if not generics. * @return a converted object * @throws Exception if conversion failed. */ protected <T> T postparse(Context context, Object value, Class<? extends T> cls, Type type) throws Exception { Converter c = null; if (value == null) { if (!cls.isPrimitive()) { c = NullConverter.INSTANCE; } } else { JSONHint hint = context.getHint(); if (hint == null) { // no handle } else if (hint.serialized() && hint != context.skipHint) { c = FormatConverter.INSTANCE; } else if (Serializable.class.equals(hint.type())) { c = SerializableConverter.INSTANCE; } else if (String.class.equals(hint.type())) { c = StringSerializableConverter.INSTANCE; } } if (c == null) { if (value != null && cls.equals(type) && cls.isAssignableFrom(value.getClass())) { c = PlainConverter.INSTANCE; } else { c = CONVERT_MAP.get(cls); } } if (c == null && context.memberCache != null) { c = (Converter) context.memberCache.get(cls); } if (c == null) { if (Properties.class.isAssignableFrom(cls)) { c = PropertiesConverter.INSTANCE; } else if (Map.class.isAssignableFrom(cls)) { c = MapConverter.INSTANCE; } else if (Collection.class.isAssignableFrom(cls)) { c = CollectionConverter.INSTANCE; } else if (cls.isArray()) { c = ArrayConverter.INSTANCE; } else if (cls.isEnum()) { c = EnumConverter.INSTANCE; } else if (Date.class.isAssignableFrom(cls)) { c = DateConverter.INSTANCE; } else if (Calendar.class.isAssignableFrom(cls)) { c = CalendarConverter.INSTANCE; } else if (CharSequence.class.isAssignableFrom(cls)) { c = CharSequenceConverter.INSTANCE; } else if (Appendable.class.isAssignableFrom(cls)) { c = AppendableConverter.INSTANCE; } else if (cls.equals(ClassUtil.findClass("java.net.InetAddress"))) { c = InetAddressConverter.INSTANCE; } else if (java.sql.Array.class.isAssignableFrom(cls) || Struct.class.isAssignableFrom(cls)) { c = NullConverter.INSTANCE; } else { c = new ObjectConverter(cls); } if (context.memberCache == null) { context.memberCache = new HashMap<Class<?>, Object>(); } context.memberCache.put(cls, c); } if (c != null) { @SuppressWarnings("unchecked") T ret = (T) c.convert(context, value, cls, type); return ret; } else { throw new UnsupportedOperationException(); } }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
private static String getCppType(Class<?> clss, Class<?> relClass) { if (clss.isArray()) { Class<?> componentType = clss.getComponentType(); return getCppArrayType(componentType); }/*w w w. ja v a 2s . com*/ if (clss.isPrimitive()) { return getCppPrimitiveType(clss); } if (Void.class.isAssignableFrom(clss)) { return "void"; } else if (isString(clss)) { return "jstring"; } else { return getCppRelativeName(clss, relClass); } }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
private static String getEasyCallCppType(Class<?> clss, Class<?> relClass) { if (clss.isArray()) { Class<?> componentType = clss.getComponentType(); return getCppEasyCallArrayType(componentType); }/* w ww. ja va2 s. co m*/ if (clss.isPrimitive()) { return getCppPrimitiveType(clss); } if (Void.class.isAssignableFrom(clss)) { return "void"; } else if (isString(clss)) { return "const char *"; } else { return getCppRelativeName(clss, relClass); } }
From source file:org.mwc.debrief.editable.test.EditableTests.java
private Editable getEditable(IType type) { Editable editable = null;/* w w w . j a v a2 s .com*/ switch (type.getFullyQualifiedName()) { case "Debrief.Wrappers.SensorWrapper": SensorWrapper sensor = new SensorWrapper("tester"); final java.util.Calendar cal = new java.util.GregorianCalendar(2001, 10, 4, 4, 4, 0); // and create the list of sensor contact data items cal.set(2001, 10, 4, 4, 4, 0); sensor.add(new SensorContactWrapper("tester", new HiResDate(cal.getTime().getTime()), null, null, null, null, null, 1, sensor.getName())); cal.set(2001, 10, 4, 4, 4, 23); sensor.add(new SensorContactWrapper("tester", new HiResDate(cal.getTime().getTime()), null, null, null, null, null, 1, sensor.getName())); editable = sensor; break; case "MWC.GUI.Shapes.ChartFolio": editable = new ChartFolio(false, Color.white); break; case "org.mwc.cmap.naturalearth.wrapper.NELayer": editable = new NELayer(Activator.getDefault().getDefaultStyleSet()); break; case "MWC.GUI.VPF.CoverageLayer$ReferenceCoverageLayer": final LibrarySelectionTable LST = null; final DebriefFeatureWarehouse myWarehouse = new DebriefFeatureWarehouse(); final FeaturePainter fp = new FeaturePainter("libref", "Coastline"); fp.setVisible(true); editable = new CoverageLayer.ReferenceCoverageLayer(LST, myWarehouse, "libref", "libref", "Coastline", fp); break; case "MWC.GUI.Chart.Painters.ETOPOPainter": editable = new ETOPOPainter("etopo", null); break; case "MWC.GUI.ETOPO.ETOPO_2_Minute": editable = new ETOPO_2_Minute("etopo"); break; case "MWC.GUI.ExternallyManagedDataLayer": editable = new ExternallyManagedDataLayer("test", "test", "test"); break; case "MWC.GUI.Shapes.CircleShape": editable = new CircleShape(new WorldLocation(2d, 2d, 2d), 2d); break; case "Debrief.Wrappers.Track.SplittableLayer": editable = new SplittableLayer(true); break; case "org.mwc.debrief.satc_interface.data.SATC_Solution": final ISolversManager solvMgr = SATC_Activator.getDefault().getService(ISolversManager.class, true); final ISolver newSolution = solvMgr.createSolver("test"); editable = new SATC_Solution(newSolution); break; case "MWC.GUI.Shapes.PolygonShape": editable = new PolygonShape(null); break; case "ASSET.GUI.Painters.NoiseSourcePainter": editable = new ASSET.GUI.Painters.NoiseSourcePainter.PainterTest().getEditable(); break; case "ASSET.GUI.Painters.ScenarioNoiseLevelPainter": editable = new ASSET.GUI.Painters.ScenarioNoiseLevelPainter.NoiseLevelTest().getEditable(); break; case "ASSET.GUI.Workbench.Plotters.ScenarioParticipantWrapper": editable = new ScenarioParticipantWrapper(new SSN(12), null); break; case "Debrief.Wrappers.PolygonWrapper": // get centre of area WorldLocation centre = new WorldLocation(12, 12, 12); // create the shape, based on the centre final Vector<PolygonNode> path2 = new Vector<PolygonNode>(); final PolygonShape newShape = new PolygonShape(path2); // and now wrap the shape final PolygonWrapper theWrapper = new PolygonWrapper("New Polygon", newShape, PlainShape.DEFAULT_COLOR, null); // store the new point newShape.add(new PolygonNode("1", centre, (PolygonShape) theWrapper.getShape())); editable = theWrapper; break; case "Debrief.Wrappers.Track.AbsoluteTMASegment": WorldSpeed speed = new WorldSpeed(5, WorldSpeed.Kts); double course = 33; WorldLocation origin = new WorldLocation(12, 12, 12); HiResDate startTime = new HiResDate(11 * 60 * 1000); HiResDate endTime = new HiResDate(17 * 60 * 1000); editable = new AbsoluteTMASegment(course, speed, origin, startTime, endTime); break; case "Debrief.Wrappers.Track.RelativeTMASegment": speed = new WorldSpeed(5, WorldSpeed.Kts); course = 33; final WorldVector offset = new WorldVector(12, 12, 0); editable = new RelativeTMASegment(course, speed, offset, null); break; case "Debrief.Wrappers.Track.PlanningSegment": speed = new WorldSpeed(5, WorldSpeed.Kts); course = 33; final WorldDistance worldDistance = new WorldDistance(5, WorldDistance.MINUTES); editable = new PlanningSegment("test", course, speed, worldDistance, Color.WHITE); break; case "org.mwc.debrief.satc_interface.data.wrappers.BMC_Wrapper": BearingMeasurementContribution bmc = new BearingMeasurementContribution(); bmc.setName("Measured bearing"); bmc.setAutoDetect(false); editable = new BMC_Wrapper(bmc); break; case "org.mwc.debrief.satc_interface.data.wrappers.FMC_Wrapper": FrequencyMeasurementContribution fmc = new FrequencyMeasurementContribution(); fmc.setName("Measured frequence"); editable = new FMC_Wrapper(fmc); break; case "Debrief.Wrappers.SensorContactWrapper": origin = new WorldLocation(0, 0, 0); editable = new SensorContactWrapper("blank track", new HiResDate(new java.util.Date().getTime()), new WorldDistance(1, WorldDistance.DEGS), 55d, origin, java.awt.Color.red, "my label", 1, "theSensorName"); break; case "Debrief.Wrappers.FixWrapper": final Fix fx = new Fix(new HiResDate(12, 0), new WorldLocation(2d, 2d, 2d), 2d, 2d); final TrackWrapper tw = new TrackWrapper(); tw.setName("here ew arw"); FixWrapper ed = new FixWrapper(fx); ed.setTrackWrapper(tw); editable = ed; break; case "Debrief.Wrappers.ShapeWrapper": centre = new WorldLocation(2d, 2d, 2d); editable = new ShapeWrapper("new ellipse", new EllipseShape(centre, 0, new WorldDistance(0, WorldDistance.DEGS), new WorldDistance(0, WorldDistance.DEGS)), java.awt.Color.red, null); break; case "Debrief.GUI.Tote.Painters.PainterManager": final StepControl stepper = new Debrief.GUI.Tote.Swing.SwingStepControl(null, null, null, null, null, null); editable = new PainterManager(stepper); break; case "Debrief.Wrappers.TMAContactWrapper": origin = new WorldLocation(2, 2, 0); final HiResDate theDTG = new HiResDate(new java.util.Date().getTime()); final EllipseShape theEllipse = new EllipseShape(origin, 45, new WorldDistance(10, WorldDistance.DEGS), new WorldDistance(5, WorldDistance.DEGS)); theEllipse.setName("test ellipse"); editable = new TMAContactWrapper("blank sensor", "blank track", theDTG, origin, 5d, 6d, 1d, Color.pink, "my label", theEllipse, "some symbol"); break; case "MWC.GUI.JFreeChart.NewFormattedJFreeChart": XYPlot plot = new XYPlot(); DefaultXYItemRenderer renderer = new DefaultXYItemRenderer(); plot.setRenderer(renderer); editable = new NewFormattedJFreeChart("test", new java.awt.Font("Dialog", 0, 18), plot, false); break; case "org.mwc.cmap.core.ui_support.swt.SWTCanvasAdapter": final Editable[] edit = new Editable[1]; Display.getDefault().syncExec(new Runnable() { @Override public void run() { edit[0] = new SWTCanvasAdapter(null); } }); editable = edit[0]; break; case "ASSET.Models.Decision.Conditions.OrCondition": System.out.println(type.getFullyQualifiedName() + " hasn't public constructor."); return null; case "ASSET.Models.Decision.Movement.RectangleWander": final WorldLocation topLeft = SupportTesting.createLocation(0, 10000); final WorldLocation bottomRight = SupportTesting.createLocation(10000, 0); final WorldArea theArea = new WorldArea(topLeft, bottomRight); editable = new RectangleWander(theArea, "rect wander"); break; case "org.mwc.debrief.satc_interface.data.wrappers.BMC_Wrapper$BearingMeasurementWrapper": bmc = new BearingMeasurementContribution(); bmc.setName("Measured bearing"); bmc.setAutoDetect(false); CoreMeasurement cm = new CoreMeasurement(new Date()); BMC_Wrapper bmcw = new BMC_Wrapper(bmc); editable = bmcw.new BearingMeasurementWrapper(cm); break; case "org.mwc.debrief.satc_interface.data.wrappers.FMC_Wrapper$FrequencyMeasurementEditable": fmc = new FrequencyMeasurementContribution(); fmc.setName("Measured frequence"); FMC_Wrapper fmcw = new FMC_Wrapper(fmc); cm = new CoreMeasurement(new Date()); editable = fmcw.new FrequencyMeasurementEditable(cm); break; case "ASSET.GUI.SuperSearch.Plotters.SSGuiSupport$ParticipantListener": SSGuiSupport ssgs = new SSGuiSupport(); ssgs.setScenario(new MultiForceScenario()); editable = new SSGuiSupport.ParticipantListener(new CoreParticipant(12), ssgs); break; case "ASSET.GUI.Workbench.Plotters.BasePlottable": // skip it return null; case "MWC.TacticalData.GND.GTrack": // skip it return null; default: break; } if (editable != null) { return editable; } Class<?> clazz; try { clazz = Class.forName(type.getFullyQualifiedName()); } catch (ClassNotFoundException e1) { //e1.printStackTrace(); System.out.println("CNFE " + e1.getMessage() + " " + type.getFullyQualifiedName()); return null; } try { @SuppressWarnings("unused") Method infoMethod = clazz.getDeclaredMethod("getInfo", new Class[0]); } catch (Exception e) { return null; } try { editable = (Editable) clazz.newInstance(); } catch (Exception e) { Constructor<?>[] constructors = clazz.getConstructors(); for (Constructor<?> constructor : constructors) { try { Class<?>[] paramTypes = constructor.getParameterTypes(); Object[] params = new Object[paramTypes.length]; for (int i = 0; i < paramTypes.length; i++) { Class<?> paramType = paramTypes[i]; if (HiResDate.class.equals(paramType)) { params[i] = new HiResDate(new Date()); } else if (WorldDistance.class.equals(paramType)) { params[i] = new WorldDistance(12d, WorldDistance.DEGS); } else if (WorldSpeed.class.equals(paramType)) { params[i] = new WorldSpeed(12, WorldSpeed.M_sec); } else if (WorldLocation.class.equals(paramType)) { params[i] = new WorldLocation(12, 12, 12); } else if ("java.lang.String".equals(paramType.getName())) { params[i] = "test"; } else if (!paramType.isPrimitive()) { params[i] = null; } else { if (paramType.equals(int.class)) { params[i] = new Integer("0"); } if (paramType.equals(boolean.class)) { params[i] = Boolean.FALSE; } if (paramType.equals(long.class)) { params[i] = new Long("0"); } if (paramType.equals(double.class)) { params[i] = new Double("0"); } if (paramType.equals(float.class)) { params[i] = new Float("0"); } if (paramType.equals(short.class)) { params[i] = new Short("0"); } } } editable = (Editable) constructor.newInstance(params); break; } catch (Exception e1) { // ignore //System.out.println(e1.getMessage()); //e1.printStackTrace(); } } } if (editable == null) { System.out.println("Can't instantiate type " + type.getFullyQualifiedName()); } return editable; }
From source file:com.impetus.client.cassandra.pelops.PelopsDataHandler.java
/** * @param superColumnClass/*from w w w. jav a 2 s . co m*/ * @param value * @param columnField * @return */ private Object populateColumnValue(Class superColumnClass, Object value, Field columnField) { Object superColumnObj; if (superColumnClass.isPrimitive()) { superColumnObj = value; } else { superColumnObj = PropertyAccessorHelper.getObject(superColumnClass); PropertyAccessorHelper.set(superColumnObj, columnField, value); } return superColumnObj; }
From source file:com.amalto.core.metadata.ClassRepository.java
private TypeMetadata loadClass(Class clazz) { String typeName = getTypeName(clazz); if (getType(typeName) != null) { // If already defined return it. return getType(typeName); } else if (getNonInstantiableType(StringUtils.EMPTY, typeName) != null) { return getNonInstantiableType(StringUtils.EMPTY, typeName); }/*from w w w .j a v a2s . co m*/ entityToJavaClass.put(typeName, clazz); if (Map.class.isAssignableFrom(clazz)) { return MAP_TYPE; } if (ArrayListHolder.class.equals(clazz)) { typeName = typeName + listCounter++; } boolean isEntity = typeStack.isEmpty(); ComplexTypeMetadata classType = new ComplexTypeMetadataImpl(StringUtils.EMPTY, typeName, isEntity); addTypeMetadata(classType); typeStack.push(classType); String keyFieldName = ""; //$NON-NLS-1$ if (isEntity && ObjectPOJO.class.isAssignableFrom(clazz)) { SimpleTypeFieldMetadata keyField = new SimpleTypeFieldMetadata(typeStack.peek(), true, false, true, "unique-id", //$NON-NLS-1$ STRING, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), StringUtils.EMPTY); keyField.setData(LINK, "PK/unique-id"); //$NON-NLS-1$ classType.addField(keyField); } else if (isEntity) { keyFieldName = "unique-id"; //$NON-NLS-1$ } // Class is abstract / interface: load sub classes if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) { Iterable<Class> subClasses = getSubclasses(clazz); ComplexTypeMetadata superType = typeStack.peek(); if (superType.isInstantiable()) { typeStack.clear(); } for (Class subClass : subClasses) { TypeMetadata typeMetadata = loadClass(subClass); typeMetadata.setInstantiable(superType.isInstantiable()); typeMetadata.addSuperType(superType); } if (superType.isInstantiable()) { typeStack.push(superType); } } // Analyze methods Method[] classMethods = getMethods(clazz); for (Method declaredMethod : classMethods) { if (!Modifier.isStatic(declaredMethod.getModifiers())) { if (isBeanMethod(declaredMethod) && isClassMethod(clazz, declaredMethod)) { String fieldName = getName(declaredMethod); if (typeStack.peek().hasField(fieldName)) { continue; // TODO Avoid override of fields (like PK) } Class<?> returnType = declaredMethod.getReturnType(); FieldMetadata newField; boolean isMany = false; boolean isKey = keyFieldName.equals(fieldName); if (Iterable.class.isAssignableFrom(returnType)) { returnType = listItemType != null ? listItemType : getListItemClass(declaredMethod, returnType); listItemType = null; isMany = true; } else if (ArrayListHolder.class.isAssignableFrom(returnType)) { listItemType = getListItemClass(declaredMethod, returnType); isMany = false; } else if (Map.class.isAssignableFrom(returnType)) { isMany = true; } else if (returnType.isArray()) { isMany = true; returnType = ((Class) returnType.getComponentType()); } else if (returnType.getName().startsWith("org.w3c.")) { //$NON-NLS-1$ // TODO Serialized XML to string column continue; } else if (Class.class.equals(returnType)) { continue; } else if (returnType.getPackage() != null && returnType.getPackage().getName().startsWith("java.io")) { //$NON-NLS-1$ continue; } if (returnType.isPrimitive() || returnType.getName().startsWith(JAVA_LANG_PREFIX)) { String fieldTypeName = returnType.getName().toLowerCase(); if (fieldTypeName.startsWith(JAVA_LANG_PREFIX)) { fieldTypeName = StringUtils.substringAfter(fieldTypeName, JAVA_LANG_PREFIX); } TypeMetadata fieldType; if (Types.BYTE.equals(fieldTypeName) && isMany) { fieldType = new SimpleTypeMetadata(XMLConstants.W3C_XML_SCHEMA_NS_URI, Types.BASE64_BINARY); } else { fieldType = new SimpleTypeMetadata(XMLConstants.W3C_XML_SCHEMA_NS_URI, fieldTypeName); } newField = new SimpleTypeFieldMetadata(typeStack.peek(), isKey, isMany, isKey, fieldName, fieldType, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), StringUtils.EMPTY); LongString annotation = declaredMethod.getAnnotation(LongString.class); if (Types.STRING.equals(fieldTypeName) && annotation != null) { fieldType.setData(MetadataRepository.DATA_MAX_LENGTH, String.valueOf(Integer.MAX_VALUE)); if (annotation.preferLongVarchar()) { fieldType.setData(LongString.PREFER_LONGVARCHAR, Boolean.TRUE); } } } else { ComplexTypeMetadata fieldType; if (Map.class.isAssignableFrom(returnType)) { fieldType = MAP_TYPE; } else { fieldType = (ComplexTypeMetadata) loadClass(returnType); } if (!isEntity || !fieldType.isInstantiable()) { newField = new ContainedTypeFieldMetadata(typeStack.peek(), isMany, false, fieldName, new SoftTypeRef(this, StringUtils.EMPTY, fieldType.getName(), false), Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), StringUtils.EMPTY); } else { newField = new ReferenceFieldMetadata(typeStack.peek(), false, isMany, false, fieldName, fieldType, fieldType.getField("unique-id"), //$NON-NLS-1$ Collections.<FieldMetadata>emptyList(), StringUtils.EMPTY, true, false, STRING, Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), StringUtils.EMPTY, StringUtils.EMPTY); } } typeStack.peek().addField(newField); } } } typeStack.peek().addField(new SimpleTypeFieldMetadata(typeStack.peek(), false, false, false, "digest", //$NON-NLS-1$ new SimpleTypeMetadata(XMLConstants.W3C_XML_SCHEMA_NS_URI, Types.STRING), Collections.<String>emptyList(), Collections.<String>emptyList(), Collections.<String>emptyList(), StringUtils.EMPTY)); return typeStack.pop(); }
From source file:fr.certu.chouette.command.Command.java
/** * @param objectType/* ww w. ja va2 s. co m*/ * @param field * @param indent * @throws Exception */ private void printField(Class<?> objectType, Field field, String indent) throws Exception { String fieldName = field.getName().toLowerCase(); if (fieldName.equals("importeditems")) return; if (fieldName.endsWith("id") || fieldName.endsWith("ids")) { if (!fieldName.equals("objectid") && !fieldName.equals("creatorid") && !fieldName.equals("areacentroid")) return; } if (findAccessor(objectType, field.getName(), "get", false) == null && findAccessor(objectType, field.getName(), "is", false) == null) { return; } Class<?> type = field.getType(); if (type.isPrimitive()) { System.out.print(indent + "- " + field.getName()); System.out.print(" : type " + type.getName()); if (findAccessor(objectType, field.getName(), "set", false) == null) { System.out.print(" (readonly)"); } } else { if (type.getSimpleName().equals("List")) { String name = field.getName(); name = name.substring(0, name.length() - 1); ParameterizedType ptype = (ParameterizedType) field.getGenericType(); Class<?> itemType = (Class<?>) ptype.getActualTypeArguments()[0]; System.out.print(indent + "- " + name); System.out.print(" : collection of type " + itemType.getSimpleName()); if (findAccessor(objectType, name, "add", false) != null) { System.out.print(" (add allowed)"); } if (findAccessor(objectType, name, "remove", false) != null) { System.out.print(" (remove allowed)"); } type = itemType; } else { System.out.print(indent + "- " + field.getName()); System.out.print(" : type " + type.getSimpleName()); if (findAccessor(objectType, field.getName(), "set", false) == null) { System.out.print(" (readonly)"); } } } System.out.println(""); if (!type.isPrimitive()) printFieldDetails(type, indent); }