public IDGenerator(int startIndex, int gap) { AssertUtils.assertTrue(startIndex >= 0, "Startindex must be grater than or equal to 0."); AssertUtils.assertTrue(gap > 0, "Gap must be grater than 0."); this.gap = gap; this.idGenerator = new AtomicInteger(startIndex); }
public static int countWSDLandXSDs(String url) throws ParseException, XMLStreamException, IOException { int sum = 1; List<String> xsds = WSDLUtil.getXSDs(AssertUtils.getAndAssert200(url)); for (String xsd : xsds) sum += countWSDLandXSDs(new URL(new URL(url), xsd).toString()); return sum; }
/** * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. * * <p>如向上转型到Object仍无法找到, 返回null. */ public static Field getAccessibleField(final Object obj, final String fieldName) { AssertUtils.notNull(obj, "object不能为空"); AssertUtils.hasText(fieldName, "fieldName"); for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { Field field = superClass.getDeclaredField(fieldName); field.setAccessible(true); return field; } catch (NoSuchFieldException e) { // NOSONAR // Field不在当前类定义,继续向上转型 } } return null; }
/** * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. 如向上转型到Object仍无法找到, 返回null. * * <p>用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethod( final Object obj, final String methodName, final Class<?>... parameterTypes) { AssertUtils.notNull(obj, "object不能为空"); for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { Method method = superClass.getDeclaredMethod(methodName, parameterTypes); method.setAccessible(true); return method; } catch (NoSuchMethodException e) { // NOSONAR // Method不在当前类定义,继续向上转型 } } return null; }