Jeeva D:
私はポストのためのコードを書いていますが、私は検証中にいくつかの問題に直面しています。
getDocumentIdsは、整数のリストであると私は必要なのは、その特定のIDが有効であるかどうかをリストし、チェックを反復処理することです。
私はそれが最初の値のみを取っている値のリストを渡すとき、私は、コードの下で試みたが、しています。これは、最初の1の後の値を取っていません。
Document document=
Optional.ofNullable(repositoryService.findById(Document.class,
memberNoteResource.getDocumentIds().stream()
.iterator().next())).orElse(null);
if (document == null) {
throw new ApiException(ApiErrorCode.DEFAULT_400,
"Save unsuccessful document id is not part of member note");
}
期待される結果は、私が渡されたすべての「getDocumentIds」をチェックする必要があり、いくつかのIDが存在しない場合、私はエラーをスローする必要があり、
また:
getDocumentIds
整数と私は必要なのリストがあるされ、リストを反復処理し、その特定のIDが有効であるかどうかをチェックします。
あなたは使用することができますanyMatch
のいずれかのために、かどうかを検証するためにid
、(戻り値を仮定して何の文書が存在しませんnull
)。
if(memberNoteResource.getDocumentIds()
.stream()
.anyMatch((id)-> repositoryService.findById(Document.class,id) == null)) {
throw new ApiException(ApiErrorCode.DEFAULT_400,
"Save unsuccessful document id is not part of member note");
}