-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d20feb7
commit 90387f9
Showing
4 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.folio.linked.data.util; | ||
|
||
import static org.apache.commons.collections4.CollectionUtils.isEmpty; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.folio.linked.data.domain.dto.LccnRequest; | ||
|
||
@UtilityClass | ||
public class LccnUtils { | ||
|
||
public static boolean isCurrent(LccnRequest lccnRequest) { | ||
return isEmpty(lccnRequest.getStatus()) || lccnRequest.getStatus() | ||
.stream() | ||
.flatMap(status -> status.getLink().stream()) | ||
.anyMatch(link -> link.endsWith("current")); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/org/folio/linked/data/validation/dto/LccnPatternValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
src/main/java/org/folio/linked/data/validation/dto/LccnValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
package org.folio.linked.data.validation.dto; | ||
|
||
import static org.apache.commons.collections4.CollectionUtils.isEmpty; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import java.lang.annotation.Annotation; | ||
import org.folio.linked.data.domain.dto.LccnRequest; | ||
|
||
public abstract class LccnValidator<A extends Annotation, T> implements ConstraintValidator<A, T> { | ||
|
||
protected boolean isCurrent(LccnRequest lccnRequest) { | ||
return isEmpty(lccnRequest.getStatus()) || lccnRequest.getStatus() | ||
.stream() | ||
.flatMap(status -> status.getLink().stream()) | ||
.anyMatch(link -> link.endsWith("current")); | ||
} | ||
} |