@Test public void getSessionFieldReturnsEmptySetWhenObjectDoesNotContainAnyFieldWithHibersapSessionAnnotation() { Set<Field> fields = ReflectionUtil.getHibersapSessionFields(new Object()); assertThat(fields).isNotNull(); assertThat(fields).hasSize(0); }
public static Set<Field> getHibersapSessionFields(final Object target) { HashSet<Field> fields = new HashSet<>(); Field[] declaredFields = target.getClass().getDeclaredFields(); for (Field declaredField : declaredFields) { if (declaredField.getAnnotation(HibersapSession.class) != null) { fields.add(declaredField); } } return fields; }
ReflectionUtil { public static Set<Field> getHibersapSessionFields(final Object target) { HashSet<Field> fields = new HashSet<>(); Field[] declaredFields = target.getClass().getDeclaredFields(); for (Field declaredField : declaredFields) { if (declaredField.getAnnotation(HibersapSession.class) != null) { fields.add(declaredField); } } return fields; } }
ReflectionUtil { public static Set<Field> getHibersapSessionFields(final Object target) { HashSet<Field> fields = new HashSet<>(); Field[] declaredFields = target.getClass().getDeclaredFields(); for (Field declaredField : declaredFields) { if (declaredField.getAnnotation(HibersapSession.class) != null) { fields.add(declaredField); } } return fields; } private  ReflectionUtil(); }
ReflectionUtil { public static Set<Field> getHibersapSessionFields(final Object target) { HashSet<Field> fields = new HashSet<>(); Field[] declaredFields = target.getClass().getDeclaredFields(); for (Field declaredField : declaredFields) { if (declaredField.getAnnotation(HibersapSession.class) != null) { fields.add(declaredField); } } return fields; } private  ReflectionUtil(); static Set<Field> getHibersapSessionFields(final Object target); static String getSessionManagerJndiName(final Field sessionField); static void injectSessionIntoTarget(final Object target, final Field field, final Session session); }
ReflectionUtil { public static Set<Field> getHibersapSessionFields(final Object target) { HashSet<Field> fields = new HashSet<>(); Field[] declaredFields = target.getClass().getDeclaredFields(); for (Field declaredField : declaredFields) { if (declaredField.getAnnotation(HibersapSession.class) != null) { fields.add(declaredField); } } return fields; } private  ReflectionUtil(); static Set<Field> getHibersapSessionFields(final Object target); static String getSessionManagerJndiName(final Field sessionField); static void injectSessionIntoTarget(final Object target, final Field field, final Session session);  }