/** * Returns a list of all the parent classes of the specified class including the class itself. * * @param c The class to retrieve the parent classes. * @param parentFirst In parent-to-child order, otherwise child-to-parent. * @param includeInterfaces Include interfaces. * @return An iterator of parent classes in the class hierarchy. */ public static Iterator<Class<?>> getParentClasses(final Class<?> c, boolean parentFirst, boolean includeInterfaces) { List<Class<?>> l = getParentClasses(new ArrayList<Class<?>>(), c, parentFirst, includeInterfaces); return l.iterator(); }
/** * Returns a list of all the parent classes of the specified class including the class itself. * * @param c The class to retrieve the parent classes. * @param parentFirst In parent-to-child order, otherwise child-to-parent. * @param includeInterfaces Include interfaces. * @return An iterator of parent classes in the class hierarchy. */ public static Iterator<Class<?>> getParentClasses(final Class<?> c, boolean parentFirst, boolean includeInterfaces) { List<Class<?>> l = getParentClasses(new ArrayList<Class<?>>(), c, parentFirst, includeInterfaces); return l.iterator(); }
/** * Returns a list of all the parent classes of the specified class including the class itself. * * @param c The class to retrieve the parent classes. * @param parentFirst In parent-to-child order, otherwise child-to-parent. * @param includeInterfaces Include interfaces. * @return An iterator of parent classes in the class hierarchy. */ public static Iterator<Class<?>> getParentClasses(final Class<?> c, boolean parentFirst, boolean includeInterfaces) { List<Class<?>> l = getParentClasses(new ArrayList<Class<?>>(), c, parentFirst, includeInterfaces); return l.iterator(); }
private String[] getPrefixes(Class<?> c) { String[] prefixes = prefixCache.get(c); if (prefixes == null) { Set<String> ps = new HashSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) ps.add(i.next().getSimpleName()); prefixes = ps.toArray(new String[ps.size()]); String[] p2 = prefixCache.putIfAbsent(c, prefixes); if (p2 != null) prefixes = p2; } return prefixes; }
private String[] getPrefixes(Class<?> c) { String[] prefixes = prefixCache.get(c); if (prefixes == null) { Set<String> ps = new HashSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) ps.add(i.next().getSimpleName()); prefixes = ps.toArray(new String[ps.size()]); String[] p2 = prefixCache.putIfAbsent(c, prefixes); if (p2 != null) prefixes = p2; } return prefixes; }
private String[] getPrefixes(Class<?> c) { String[] prefixes = prefixCache.get(c); if (prefixes == null) { Set<String> ps = new HashSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) ps.add(i.next().getSimpleName()); prefixes = ps.toArray(new String[ps.size()]); String[] p2 = prefixCache.putIfAbsent(c, prefixes); if (p2 != null) prefixes = p2; } return prefixes; }
private static List<Class<?>> getParentClasses(List<Class<?>> l, Class<?> c, boolean parentFirst, boolean includeInterfaces) { if (parentFirst) { if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); l.add(c); } else { l.add(c); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); } return l; }
private static List<Class<?>> getParentClasses(List<Class<?>> l, Class<?> c, boolean parentFirst, boolean includeInterfaces) { if (parentFirst) { if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); l.add(c); } else { l.add(c); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); } return l; }
private static List<Class<?>> getParentClasses(List<Class<?>> l, Class<?> c, boolean parentFirst, boolean includeInterfaces) { if (parentFirst) { if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); l.add(c); } else { l.add(c); if (c.getSuperclass() != Object.class && c.getSuperclass() != null) getParentClasses(l, c.getSuperclass(), parentFirst, includeInterfaces); if (includeInterfaces) for (Class<?> i : c.getInterfaces()) l.add(i); } return l; }
/** * Returns the {@link #BEAN_includeProperties} setting for the specified class. * * @param c The class. * @return The properties to include for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getIncludeProperties(Class<?> c) { if (includeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = includeProperties.get(c2.getName()); if (s != null) return s; s = includeProperties.get(c2.getSimpleName()); if (s != null) return s; } return includeProperties.get("*"); }
/** * Returns the {@link #BEAN_includeProperties} setting for the specified class. * * @param c The class. * @return The properties to include for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getIncludeProperties(Class<?> c) { if (includeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = includeProperties.get(c2.getName()); if (s != null) return s; s = includeProperties.get(c2.getSimpleName()); if (s != null) return s; } return includeProperties.get("*"); }
/** * Returns the {@link #BEAN_includeProperties} setting for the specified class. * * @param c The class. * @return The properties to include for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getIncludeProperties(Class<?> c) { if (includeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = includeProperties.get(c2.getName()); if (s != null) return s; s = includeProperties.get(c2.getSimpleName()); if (s != null) return s; } return includeProperties.get("*"); }
/** * Returns the {@link #BEAN_excludeProperties} setting for the specified class. * * @param c The class. * @return The properties to exclude for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getExcludeProperties(Class<?> c) { if (excludeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = excludeProperties.get(c2.getName()); if (s != null) return s; s = excludeProperties.get(c2.getSimpleName()); if (s != null) return s; } return excludeProperties.get("*"); }
/** * Returns the {@link #BEAN_excludeProperties} setting for the specified class. * * @param c The class. * @return The properties to exclude for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getExcludeProperties(Class<?> c) { if (excludeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = excludeProperties.get(c2.getName()); if (s != null) return s; s = excludeProperties.get(c2.getSimpleName()); if (s != null) return s; } return excludeProperties.get("*"); }
/** * Returns the {@link #BEAN_excludeProperties} setting for the specified class. * * @param c The class. * @return The properties to exclude for the specified class, or <jk>null</jk> if it's not defined for the class. */ protected String[] getExcludeProperties(Class<?> c) { if (excludeProperties.isEmpty()) return null; String[] s = null; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(c, false, true); i.hasNext();) { Class<?> c2 = i.next(); s = excludeProperties.get(c2.getName()); if (s != null) return s; s = excludeProperties.get(c2.getSimpleName()); if (s != null) return s; } return excludeProperties.get("*"); }
@Test public void getParentClassesParentFirst() throws Exception { Set<String> s = new TreeSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(CD.class, true, true); i.hasNext();) { Class<?> c = i.next(); s.add(c.getSimpleName()); } assertObjectEquals("['CA1','CA2','CA3','CB','CC','CD']", s); s = new TreeSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(CD.class, true, false); i.hasNext();) { Class<?> c = i.next(); s.add(c.getSimpleName()); } assertObjectEquals("['CB','CC','CD']", s); s = new TreeSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(CD.class, false, true); i.hasNext();) { Class<?> c = i.next(); s.add(c.getSimpleName()); } assertObjectEquals("['CA1','CA2','CA3','CB','CC','CD']", s); s = new TreeSet<>(); for (Iterator<Class<?>> i = ClassUtils.getParentClasses(CD.class, false, false); i.hasNext();) { Class<?> c = i.next(); s.add(c.getSimpleName()); } assertObjectEquals("['CB','CC','CD']", s); }
return t == NULL ? null : t; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(ic, false, true); i.hasNext(); ) { Class pic = i.next(); t = m.get(pic);
return t == NULL ? null : t; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(ic, false, true); i.hasNext(); ) { Class pic = i.next(); t = m.get(pic);
return t == NULL ? null : t; for (Iterator<Class<?>> i = ClassUtils.getParentClasses(ic, false, true); i.hasNext(); ) { Class pic = i.next(); t = m.get(pic);