int (@NotNull Object o) { Queue<Class<?>> toCheck = new ArrayDeque<>(); toCheck.add(o.getClass()); while (!toCheck.isEmpty()) { Class<?> clazz = toCheck.poll(); Order annotation = clazz.getAnnotation(Order.class); if (annotation != null) { return annotation.value(); } Class<?> c = clazz.getSuperclass(); if (c != null) { toCheck.add(c); } Class<?>[] interfaces = clazz.getInterfaces(); Collections.addAll(toCheck, interfaces); } return ExternalSystemConstants.UNORDERED; }