/** * Searches the current debug scope, bottom up, for a context object that is an instance of a * given type. The first such object found is returned. */ @SuppressWarnings("unchecked") public static <T> T contextLookup(Class<T> clazz) { if (ENABLED) { for (Object o : context()) { if (clazz.isInstance(o)) { return ((T) o); } } } return null; }
@SuppressWarnings("unchecked") public static <T> List<T> contextSnapshot(Class<T> clazz) { if (ENABLED) { List<T> result = new ArrayList<>(); for (Object o : context()) { if (clazz.isInstance(o)) { result.add((T) o); } } return result; } else { return Collections.emptyList(); } }