This commit is contained in:
parent
c7d22ae3d1
commit
995a97a69c
2 changed files with 10 additions and 1 deletions
|
|
@ -1,16 +1,25 @@
|
||||||
package ru.nbch.credit_tracker.component.comparator;
|
package ru.nbch.credit_tracker.component.comparator;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.function.ToIntFunction;
|
import java.util.function.ToIntFunction;
|
||||||
import ru.nbch.credit_tracker.entities.app.UserPackage;
|
import ru.nbch.credit_tracker.entities.app.UserPackage;
|
||||||
import ru.nbch.credit_tracker.enums.Status;
|
import ru.nbch.credit_tracker.enums.Status;
|
||||||
|
|
||||||
public class ReportListPackageStatusComparator {
|
public class ReportListPackageStatusComparator {
|
||||||
|
|
||||||
|
public static final EnumSet<Status> reportedStatuses = EnumSet.of(
|
||||||
|
Status.ON_MONITORING, Status.PROCESSING_REPEATED
|
||||||
|
);
|
||||||
|
|
||||||
public static Comparator<UserPackage> INSTANCE = Comparator
|
public static Comparator<UserPackage> INSTANCE = Comparator
|
||||||
.comparingInt((ToIntFunction<UserPackage>) userPackage -> statusToInt(userPackage.getStatus()))
|
.comparingInt((ToIntFunction<UserPackage>) userPackage -> statusToInt(userPackage.getStatus()))
|
||||||
.thenComparingLong(UserPackage::getId);
|
.thenComparingLong(UserPackage::getId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* статусы не входящие в {@code reportedStatuses}
|
||||||
|
* кинут ошибку в <code>ru.nbch.credit_tracker.facade.SignalFacadeV3#getReportList</code>
|
||||||
|
*/
|
||||||
public static int statusToInt(String str) {
|
public static int statusToInt(String str) {
|
||||||
try {
|
try {
|
||||||
Status status = Status.valueOf(str);
|
Status status = Status.valueOf(str);
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ public class SignalFacadeV3 {
|
||||||
if (status.equals(Status.DELETED)) {
|
if (status.equals(Status.DELETED)) {
|
||||||
throw clientExcp(SignalError.ERROR_022, XmlErrorFormat.MonitoringReportListError, packageName);
|
throw clientExcp(SignalError.ERROR_022, XmlErrorFormat.MonitoringReportListError, packageName);
|
||||||
}
|
}
|
||||||
if (!status.equals(Status.ON_MONITORING)) {
|
if (!ReportListPackageStatusComparator.reportedStatuses.contains(status)) {
|
||||||
throw clientExcp(SignalError.ERROR_012, XmlErrorFormat.MonitoringReportListError, packageName);
|
throw clientExcp(SignalError.ERROR_012, XmlErrorFormat.MonitoringReportListError, packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue