|  | 
| 1 | 1 | package life.qbic.projectmanagement.application.api; | 
| 2 | 2 | 
 | 
|  | 3 | +import static java.util.Objects.isNull; | 
|  | 4 | + | 
|  | 5 | +import java.util.Optional; | 
| 3 | 6 | import java.util.UUID; | 
| 4 | 7 | import reactor.core.publisher.Mono; | 
| 5 | 8 | 
 | 
| @@ -123,6 +126,41 @@ public String requestId() { | 
| 123 | 126 |    */ | 
| 124 | 127 |   record ProjectUpdateResponse(String projectId, UpdateResponseBody responseBody, String requestId) { | 
| 125 | 128 | 
 | 
|  | 129 | +    public ProjectUpdateResponse { | 
|  | 130 | +      if (projectId == null) { | 
|  | 131 | +        throw new IllegalArgumentException("Project ID cannot be null"); | 
|  | 132 | +      } | 
|  | 133 | +      if (projectId.isBlank()) { | 
|  | 134 | +        throw new IllegalArgumentException("Project ID cannot be blank"); | 
|  | 135 | +      } | 
|  | 136 | +      if (requestId != null && requestId.isBlank()) { | 
|  | 137 | +        requestId = null; | 
|  | 138 | +      } | 
|  | 139 | +    } | 
|  | 140 | + | 
|  | 141 | +    /** | 
|  | 142 | +     * Retrieves the request id associated with this response. May be {@link Optional#empty()} but | 
|  | 143 | +     * never null. | 
|  | 144 | +     * | 
|  | 145 | +     * @return an Optional with the requestId; {@link Optional#empty()} otherwise. | 
|  | 146 | +     */ | 
|  | 147 | +    public Optional<String> retrieveRequestId() { | 
|  | 148 | +      return Optional.ofNullable(requestId); | 
|  | 149 | +    } | 
|  | 150 | + | 
|  | 151 | +    /** | 
|  | 152 | +     * Returns the requestId, if no requestId is set, returns an empty String. | 
|  | 153 | +     * | 
|  | 154 | +     * @return Returns the requestId, if no requestId is set, returns an empty String. | 
|  | 155 | +     */ | 
|  | 156 | +    @Override | 
|  | 157 | +    public String requestId() { | 
|  | 158 | +      return isNull(requestId) ? "" : requestId; | 
|  | 159 | +    } | 
|  | 160 | + | 
|  | 161 | +    boolean hasRequestId() { | 
|  | 162 | +      return isNull(requestId); | 
|  | 163 | +    } | 
| 126 | 164 |   } | 
| 127 | 165 | 
 | 
| 128 | 166 |   /** | 
|  | 
0 commit comments