public static OptionalEntity<LabelType> getEntity(final CreateForm form, final String username, final long currentTime) {
        switch (form.crudMode) {
        case CrudMode.CREATE:
            return OptionalEntity.of(new LabelType()).map(entity -> {
                entity.setCreatedBy(username);
                entity.setCreatedTime(currentTime);
                return entity;
            });
        case CrudMode.EDIT:
            if (form instanceof EditForm) {
                return ComponentUtil.getComponent(LabelTypeService.class).getLabelType(((EditForm) form).id);
            }
            break;
        default:
            break;
        }
        return OptionalEntity.empty();
    }
public static OptionalEntity < LabelType > getEntity ( final CreateForm form , final String username , final long currentTime ) { switch ( form . crudMode ) { case CrudMode . CREATE : return OptionalEntity . of ( new LabelType ( ) ) . map ( entity -> { entity . setCreatedBy ( username ) ; entity . setCreatedTime ( currentTime ) ; return entity ; } ) ; case CrudMode . EDIT : if ( form instanceof EditForm ) { return ComponentUtil . getComponent ( LabelTypeService . class ) . getLabelType ( ( ( EditForm ) form ) . id ) ; } break ; default : break ; } return OptionalEntity . empty ( ) ; }
============