private <T> void cascadeOperation(T theT, CascadeTest theCascadeTest, CascadeAction theAction) { // if we've already cascaded this, move on to the next thing, we don't want infinite loops if (mCascadePending.contains(theT)) { return; } else { mCascadePending.add(theT); } Collection<AccessibleObject> aAccessors = new HashSet<AccessibleObject>(); aAccessors.addAll(getAnnotatedFields(theT.getClass())); aAccessors.addAll(getAnnotatedGetters(theT.getClass(), true)); for (AccessibleObject aObj : aAccessors) { if (theCascadeTest.apply(aObj)) { try { Object aAccessorValue = BeanReflectUtil.safeGet(aObj, theT); if (aAccessorValue == null) { continue; } theAction.apply(aAccessorValue); } catch (Exception e) { throw new PersistenceException(e); } } } }