2525
2626import java .util .Date ;
2727import java .util .List ;
28+ import java .util .Optional ;
2829
2930import javax .ws .rs .core .GenericType ;
3031import javax .ws .rs .core .Response ;
@@ -147,6 +148,23 @@ public Issue getIssue(Integer projectId, Integer issueId) throws GitLabApiExcept
147148 return (response .readEntity (Issue .class ));
148149 }
149150
151+ /**
152+ * Get a single project issue as an Optional instance.
153+ *
154+ * GET /projects/:id/issues/:issue_iid
155+ *
156+ * @param projectId the project ID to get the issue for
157+ * @param issueId the internal ID of a project's issue
158+ * @return the specified Issue as an Optional instance
159+ */
160+ public Optional <Issue > getOptionalIssue (Integer projectId , Integer issueId ) {
161+ try {
162+ return (Optional .ofNullable (getIssue (projectId , issueId )));
163+ } catch (GitLabApiException glae ) {
164+ return (GitLabApi .createOptionalFromException (glae ));
165+ }
166+ }
167+
150168 /**
151169 * Create an issue for the project.
152170 *
@@ -462,13 +480,13 @@ public TimeStats resetSpentTime(Integer projectId, Integer issueIid) throws GitL
462480 }
463481
464482 /**
465- * Get time tracking stats
483+ * Get time tracking stats.
466484 *
467485 * GET /projects/:id/issues/:issue_iid/time_stats
468486 *
469487 * @param projectId the project ID that owns the issue
470488 * @param issueIid the internal ID of a project's issue
471- * @return a TimeSTats instance
489+ * @return a TimeStats instance
472490 * @throws GitLabApiException if any exception occurs
473491 */
474492 public TimeStats getTimeTrackingStats (Integer projectId , Integer issueIid ) throws GitLabApiException {
@@ -484,4 +502,21 @@ public TimeStats getTimeTrackingStats(Integer projectId, Integer issueIid) throw
484502 Response response = get (Response .Status .OK , new GitLabApiForm ().asMap (), "projects" , projectId , "issues" , issueIid , "time_stats" );
485503 return (response .readEntity (TimeStats .class ));
486504 }
505+
506+ /**
507+ * Get time tracking stats as an Optional instance
508+ *
509+ * GET /projects/:id/issues/:issue_iid/time_stats
510+ *
511+ * @param projectId the project ID that owns the issue
512+ * @param issueIid the internal ID of a project's issue
513+ * @return a TimeStats as an Optional instance
514+ */
515+ public Optional <TimeStats > getOptionalTimeTrackingStats (Integer projectId , Integer issueIid ) {
516+ try {
517+ return (Optional .ofNullable (getTimeTrackingStats (projectId , issueIid )));
518+ } catch (GitLabApiException glae ) {
519+ return (GitLabApi .createOptionalFromException (glae ));
520+ }
521+ }
487522}
0 commit comments