Integer guideNumber = Integer.valueOf(0); List<Guide> guides = new ArrayList(); for (Guide guide : RootDomainObject.getInstance().getGuides()) { if (guide.getYear().equals(year)) { guides.add(guide); } } if (!guides.isEmpty()) { Collections.sort(guides, new BeanComparator("number")); guideNumber = guides.get(0).getNumber(); } return Integer.valueOf(guideNumber.intValue() + 1);
return Collections .max(RootDomainObject.getInstance().getGuides(), Guide.yearAndNumberComparator) .getNumber() + 1;
    public static Integer generateGuideNumber(Integer year) {        Integer guideNumber = Integer.valueOf(0);        List<Guide> guides = new ArrayList();        for (Guide guide : RootDomainObject.getInstance().getGuides()) {            if (guide.getYear().equals(year)) {                guides.add(guide);            }        }        if (!guides.isEmpty()) {            Collections.sort(guides, new BeanComparator("number"));            guideNumber = guides.get(0).getNumber();        }        return Integer.valueOf(guideNumber.intValue() + 1);    }