ISSUE-925 Added delete,compact topics config (#926)
* ISSUE-925 Added delete,compact topics config * Fixed checkstyle
This commit is contained in:
parent
81a6564183
commit
07a9528d39
1 changed files with 15 additions and 5 deletions
|
@ -2,27 +2,37 @@ package com.provectus.kafka.ui.model;
|
||||||
|
|
||||||
import com.provectus.kafka.ui.exception.IllegalEntityStateException;
|
import com.provectus.kafka.ui.exception.IllegalEntityStateException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public enum CleanupPolicy {
|
public enum CleanupPolicy {
|
||||||
DELETE("delete"),
|
DELETE("delete"),
|
||||||
COMPACT("compact"),
|
COMPACT("compact"),
|
||||||
COMPACT_DELETE("compact,delete"),
|
COMPACT_DELETE(Arrays.asList("compact,delete", "delete,compact")),
|
||||||
UNKNOWN("unknown");
|
UNKNOWN("unknown");
|
||||||
|
|
||||||
private final String cleanUpPolicy;
|
private final List<String> cleanUpPolicy;
|
||||||
|
|
||||||
CleanupPolicy(String cleanUpPolicy) {
|
CleanupPolicy(String cleanUpPolicy) {
|
||||||
|
this(Collections.singletonList(cleanUpPolicy));
|
||||||
|
}
|
||||||
|
|
||||||
|
CleanupPolicy(List<String> cleanUpPolicy) {
|
||||||
this.cleanUpPolicy = cleanUpPolicy;
|
this.cleanUpPolicy = cleanUpPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCleanUpPolicy() {
|
public String getCleanUpPolicy() {
|
||||||
return cleanUpPolicy;
|
return cleanUpPolicy.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CleanupPolicy fromString(String string) {
|
public static CleanupPolicy fromString(String string) {
|
||||||
return Arrays.stream(CleanupPolicy.values())
|
return Arrays.stream(CleanupPolicy.values())
|
||||||
.filter(v -> v.cleanUpPolicy.equals(string.replace(" ", "")))
|
.filter(v ->
|
||||||
.findFirst()
|
v.cleanUpPolicy.stream().anyMatch(
|
||||||
|
s -> s.equals(string.replace(" ", "")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
).findFirst()
|
||||||
.orElseThrow(() ->
|
.orElseThrow(() ->
|
||||||
new IllegalEntityStateException("Unknown cleanup policy value: " + string));
|
new IllegalEntityStateException("Unknown cleanup policy value: " + string));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue