use of org.dbflute.optional.OptionalThingExceptionThrower in project dbflute-core by dbflute.
the class AbstractBehaviorReadable method toRelationOptional.
// ===================================================================================
// Optional Handling
// =================
/**
* Create present or null entity as relation optional.
* @param relationTitle The title of relation for exception message. (NotNull)
* @param relationRow The entity instance of relation row. (NullAllowed)
* @return The optional object for the entity, which has present or null entity. (NotNull)
*/
protected Object toRelationOptional(final String relationTitle, Object relationRow) {
assertObjectNotNull("relationTitle", relationTitle);
final RelationOptionalFactory factory = xgetROpFactory();
final Object result;
if (relationRow != null) {
result = factory.createOptionalPresentEntity(relationRow);
} else {
result = factory.createOptionalNullEntity(new OptionalThingExceptionThrower() {
public void throwNotFoundException() {
String msg = "Not found the relation row for: " + relationTitle;
throw new EntityAlreadyDeletedException(msg);
}
});
}
return result;
}
Aggregations