Simple helper method for Domino object recycling

Yesterday I’ve been asked how a simple (general) method for Domino object recycling may look like.

 public class DominoUtils {   // pass any Domino objects to this method
   public static void recycleObjects(Object... dominoObjects) {
      for (Object dominoObject : dominoObjects) {
         if (dominoObject!=null) {
            if (dominoObject instanceof lotus.domino.Base) {
               try {
                  ((lotus.domino.Base)dominoObject).recycle();
               } catch (Exception e) {
                  // do nothing
               }
            }
         }
      }
   }
} 

You can than call it from anywhere like this (in the right order):

DominoUtils.recycleObjects(docThis, vwThat, dbHere, session);

Having such a helper method makes your code cleaner instead of adding additional if/try/catch clauses for every Domino object to your code.