#747: ResultHolder.java

projectforge-business/src/main/java/org/projectforge/framework/utils/ResultHolder.java Lines: 106 · Author: Kai Reinhard · Type: Java — generic operation result container 106 lines · 61 code · 27 comments · 18 blank

Purpose

Generic result wrapper used as a return value from service methods. 106 lines. Combines a status (ResultHolderStatus: OK/WARNING/ERROR/FAILED) with a list of messages. This is ProjectForge's version of the Result pattern — instead of methods returning a value or throwing exceptions, they return a ResultHolder with accumulated messages.

Inner classes — the message model

Usage pattern

ResultHolder result = myService.doSomething();
if (result.getStatus() == ResultHolderStatus.ERROR) {
    showErrors(result.getMessages());
}

The holder accumulates messages through addMessage() — multiple validation errors can be collected before returning. Used by form validators, import operations, and setup wizard steps where multiple issues should be reported at once rather than failing on the first error.