TSK-1831: dropped support for JDK8

Co-authored-by: Yakup Ensar Evli <54323073+ensarevlideveloper@users.noreply.github.com>
Co-authored-by: ryzheboka <25465835+ryzheboka@users.noreply.github.com>
Co-authored-by: knht <43456808+knht@users.noreply.github.com>
This commit is contained in:
Mustapha Zorgati 2022-04-21 13:23:43 +02:00
parent c13e1cf6b5
commit 93d0b27bb0
26 changed files with 92 additions and 57 deletions

View File

@ -1,5 +1,7 @@
package pro.taskana.common.internal.security;
import static java.util.function.Predicate.not;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.Principal;
@ -131,7 +133,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
Set<Principal> principals = subject.getPrincipals();
LOGGER.trace("Public principals of caller: {}", principals);
return principals.stream()
.filter(principal -> !(principal instanceof GroupPrincipal))
.filter(not(GroupPrincipal.class::isInstance))
.map(Principal::getName)
.filter(Objects::nonNull)
.map(this::convertAccessId)

View File

@ -1,5 +1,7 @@
package pro.taskana.common.internal.configuration;
import static java.util.function.Predicate.not;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -110,7 +112,7 @@ public class TaskanaConfigurationInitializer {
static List<String> splitStringAndTrimElements(
String str, String separator, UnaryOperator<String> modifier) {
return Arrays.stream(str.split(Pattern.quote(separator)))
.filter(s -> !s.isEmpty())
.filter(not(String::isEmpty))
.map(String::trim)
.map(modifier)
.collect(Collectors.toList());
@ -134,7 +136,7 @@ public class TaskanaConfigurationInitializer {
.filter(m -> m.getName().toLowerCase().contains(field.getName().toLowerCase()))
.findFirst();
if (!hasSetterMethod.isPresent()) {
if (hasSetterMethod.isEmpty()) {
throw new SystemException("No setter method for " + field.getName());
}

View File

@ -1,5 +1,6 @@
package pro.taskana.common.internal.util;
import static java.util.function.Predicate.not;
import static pro.taskana.common.internal.util.CheckedFunction.wrap;
import java.lang.reflect.Field;
@ -51,9 +52,9 @@ public class ObjectAttributeChangeDetector {
List<JSONObject> changedAttributes =
ReflectionUtil.retrieveAllFields(objectClass).stream()
.peek(field -> field.setAccessible(true))
.filter(field -> !"customAttributes".equals(field.getName()))
.filter(not(field -> "customAttributes".equals(field.getName())))
.map(wrap(field -> Triplet.of(field, field.get(oldObject), field.get(newObject))))
.filter(t -> !Objects.equals(t.getMiddle(), t.getRight()))
.filter(not(t -> Objects.equals(t.getMiddle(), t.getRight())))
.map(t -> generateChangedAttribute(t.getLeft(), t.getMiddle(), t.getRight()))
.collect(Collectors.toList());

View File

@ -1,5 +1,7 @@
package pro.taskana.common.internal.util;
import static java.util.function.Predicate.not;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
@ -34,7 +36,7 @@ public class ReflectionUtil {
fields.addAll(Arrays.asList(currentClass.getDeclaredFields()));
currentClass = currentClass.getSuperclass();
}
return fields.stream().filter(f -> !f.isSynthetic()).collect(Collectors.toList());
return fields.stream().filter(not(Field::isSynthetic)).collect(Collectors.toList());
}
// safe because both Long.class and long.class are of type Class<Long>

View File

@ -1,5 +1,6 @@
package pro.taskana.simplehistory.impl.jobs;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.mapping;
import static java.util.stream.Collectors.toList;
@ -165,7 +166,8 @@ public class HistoryCleanupJob extends AbstractTaskanaJob {
(parentBusinessProcessId, taskHistoryIdsByEventType) -> {
if (taskHistoryIdsByEventType.get(TaskHistoryEventType.CREATED.getName()).size()
== taskHistoryIdsByEventType.entrySet().stream()
.filter(entry -> !entry.getKey().equals(TaskHistoryEventType.CREATED.getName()))
.filter(
not(entry -> entry.getKey().equals(TaskHistoryEventType.CREATED.getName())))
.mapToInt(stringListEntry -> stringListEntry.getValue().size())
.sum()) {
taskIdsToDeleteHistoryEventsFor.addAll(

View File

@ -134,6 +134,7 @@ public interface Classification extends ClassificationSummary {
* to be set
* @deprecated Use {@linkplain #setCustomField(ClassificationCustomField, String)} instead
*/
@Deprecated
void setCustomAttribute(ClassificationCustomField customField, String value);
/**

View File

@ -96,6 +96,7 @@ public interface ClassificationSummary {
* ClassificationCustomField}
* @deprecated Use {@linkplain #getCustomField(ClassificationCustomField)} instead
*/
@Deprecated
String getCustomAttribute(ClassificationCustomField customField);
/**

View File

@ -129,6 +129,7 @@ public interface Task extends TaskSummary {
* @param value the value of the {@linkplain TaskCustomField customField} to be set
* @deprecated Use {@linkplain #setCustomField(TaskCustomField, String)} instead
*/
@Deprecated
void setCustomAttribute(TaskCustomField customField, String value);
/**

View File

@ -268,6 +268,7 @@ public interface TaskSummary {
* @return the value for the given customField
* @deprecated Use {@linkplain #getCustomField(TaskCustomField)} instead
*/
@Deprecated
String getCustomAttribute(TaskCustomField customField);
/**

View File

@ -1,5 +1,7 @@
package pro.taskana.task.internal;
import static java.util.function.Predicate.not;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -87,7 +89,7 @@ public class AttachmentHandler {
List<Attachment> newAttachments =
newTaskImpl.getAttachments().stream()
.filter(a -> !oldAttachmentIds.contains(a.getId()))
.filter(not(a -> oldAttachmentIds.contains(a.getId())))
.collect(Collectors.toList());
for (Attachment attachment : newAttachments) {

View File

@ -1,5 +1,7 @@
package pro.taskana.task.internal;
import static java.util.function.Predicate.not;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -79,7 +81,7 @@ public class ObjectReferenceHandler {
List<ObjectReference> newObjectReferences =
newTaskImpl.getSecondaryObjectReferences().stream()
.filter(o -> !oldObjectReferencesIds.contains(o.getId()))
.filter(not(o -> oldObjectReferencesIds.contains(o.getId())))
.collect(Collectors.toList());
for (ObjectReference objectReference : newObjectReferences) {

View File

@ -1,5 +1,6 @@
package pro.taskana.task.internal;
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.groupingBy;
import java.time.Duration;
@ -71,7 +72,9 @@ class ServiceLevelHandler {
}
if (priorityChanged) {
List<MinimalTaskSummary> tasksWithoutManualPriority =
tasks.stream().filter(t -> !t.isManualPriorityActive()).collect(Collectors.toList());
tasks.stream()
.filter(not(MinimalTaskSummary::isManualPriorityActive))
.collect(Collectors.toList());
updateTaskPriorityOnClassificationUpdate(
tasksWithoutManualPriority, attachments, allInvolvedClassifications);
}

View File

@ -1,5 +1,7 @@
package pro.taskana.task.internal;
import static java.util.function.Predicate.not;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@ -955,7 +957,7 @@ public class TaskServiceImpl implements TaskService {
.collect(Collectors.toSet());
List<MinimalTaskSummary> tasksAuthorizedFor =
existingTasks.stream()
.filter(t -> !taskIdsToRemove.contains(t.getTaskId()))
.filter(not(t -> taskIdsToRemove.contains(t.getTaskId())))
.collect(Collectors.toList());
return Pair.of(tasksAuthorizedFor, bulkLog);
}
@ -969,7 +971,7 @@ public class TaskServiceImpl implements TaskService {
.map(MinimalTaskSummary::getTaskId)
.collect(Collectors.toSet());
requestTaskIds.stream()
.filter(taskId -> !existingTaskIds.contains(taskId))
.filter(not(existingTaskIds::contains))
.forEach(taskId -> bulkLog.addError(taskId, new TaskNotFoundException(taskId)));
return bulkLog;
}

View File

@ -1,5 +1,8 @@
package pro.taskana.task.internal.jobs;
import static java.util.Objects.nonNull;
import static java.util.function.Predicate.not;
import java.time.Duration;
import java.time.Instant;
import java.util.HashMap;
@ -111,9 +114,9 @@ public class TaskCleanupJob extends AbstractTaskanaJob {
List<String> taskIdsNotAllCompletedSameParentBusiness =
numberParentTasksShouldHave.entrySet().stream()
.filter(entry -> entry.getKey() != null)
.filter(entry -> !entry.getKey().isEmpty())
.filter(entry -> !entry.getValue().equals(countParentTask.get(entry.getKey())))
.filter(entry -> nonNull(entry.getKey()))
.filter(not(entry -> entry.getKey().isEmpty()))
.filter(not(entry -> entry.getValue().equals(countParentTask.get(entry.getKey()))))
.map(Map.Entry::getKey)
.collect(Collectors.toList());

View File

@ -1,5 +1,7 @@
package pro.taskana.task.internal.jobs.helper;
import static java.util.Objects.nonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalInt;
@ -83,6 +85,6 @@ public class TaskUpdatePriorityWorker {
}
public static IntPredicate hasDifferentPriority(TaskSummary taskSummary) {
return prio -> taskSummary != null && prio != taskSummary.getPriority();
return prio -> nonNull(taskSummary) && prio != taskSummary.getPriority();
}
}

View File

@ -36,6 +36,7 @@ public interface Workbasket extends WorkbasketSummary {
* @param value the value of the {@linkplain WorkbasketCustomField} to be set
* @deprecated Use {@linkplain #setCustomField(WorkbasketCustomField, String)} instead
*/
@Deprecated
void setCustomAttribute(WorkbasketCustomField customField, String value);
/**

View File

@ -66,6 +66,7 @@ public interface WorkbasketSummary {
* @return the value for the given {@linkplain WorkbasketCustomField}
* @deprecated Use {@linkplain #getCustomField(WorkbasketCustomField)} instead
*/
@Deprecated
String getCustomAttribute(WorkbasketCustomField customField);
/**

View File

@ -6,6 +6,7 @@ import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS;
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_THROW_GENERIC_EXCEPTIONS;
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
import static java.util.function.Predicate.not;
import static org.assertj.core.api.Assertions.assertThat;
import com.tngtech.archunit.base.DescribedPredicate;
@ -256,7 +257,7 @@ class ArchitectureTest {
TASKANA_SUB_PACKAGES.stream()
.map(p -> p.split("\\.")[2])
.distinct()
.filter(d -> !"common".equals(d))
.filter(not("common"::equals))
.map(d -> ".." + d + "..");
ThrowingConsumer<String> testMethod =
p ->
@ -285,7 +286,7 @@ class ArchitectureTest {
TASKANA_SUB_PACKAGES.stream()
.map(p -> p.split("\\.")[2])
.distinct()
.filter(d -> !"monitor".equals(d))
.filter(not("monitor"::equals))
.map(d -> ".." + d + "..");
ThrowingConsumer<String> testMethod =
@ -352,7 +353,7 @@ class ArchitectureTest {
}
private ArchCondition<JavaClass> implementToString() {
return new ArchCondition<JavaClass>("implement toString()") {
return new ArchCondition<>("implement toString()") {
@Override
public void check(JavaClass javaClass, ConditionEvents conditionEvents) {
boolean implementToString =
@ -371,7 +372,7 @@ class ArchitectureTest {
}
private ArchCondition<JavaClass> notImplementToString() {
return new ArchCondition<JavaClass>("not implement toString()") {
return new ArchCondition<>("not implement toString()") {
@Override
public void check(JavaClass javaClass, ConditionEvents conditionEvents) {
boolean implementToString =
@ -389,7 +390,7 @@ class ArchitectureTest {
}
private ArchCondition<JavaClass> beAnnotatedWithTestInstancePerClass() {
return new ArchCondition<JavaClass>("be annotated with @TestInstance(Lifecycle.PER_CLASS)") {
return new ArchCondition<>("be annotated with @TestInstance(Lifecycle.PER_CLASS)") {
@Override
public void check(JavaClass item, ConditionEvents events) {
Optional<TestInstance> testInstanceOptional =
@ -408,7 +409,7 @@ class ArchitectureTest {
}
private DescribedPredicate<JavaClass> areNestedTaskanaIntegrationTestClasses() {
return new DescribedPredicate<JavaClass>("are nested TaskanaIntegrationTest classes") {
return new DescribedPredicate<>("are nested TaskanaIntegrationTest classes") {
@Override
public boolean apply(JavaClass input) {
@ -431,7 +432,7 @@ class ArchitectureTest {
}
private ArchCondition<JavaClass> onlyHaveFieldsWithNoModifierAndPrivateConstants() {
return new ArchCondition<JavaClass>("only have fields with no modifier") {
return new ArchCondition<>("only have fields with no modifier") {
final Set<JavaModifier> modifiersForConstants =
Set.of(JavaModifier.PRIVATE, JavaModifier.STATIC, JavaModifier.FINAL);
@ -456,7 +457,7 @@ class ArchitectureTest {
private static ArchCondition<JavaClass> beDefinedInTaskanaSubPackages(
List<Pattern> excludePackages) {
return new ArchCondition<JavaClass>("all be defined in TASKANA_SUB_PACKAGES") {
return new ArchCondition<>("all be defined in TASKANA_SUB_PACKAGES") {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
if (TASKANA_SUB_PACKAGES.stream().noneMatch(p -> javaClass.getPackageName().startsWith(p))
@ -529,7 +530,7 @@ class ArchitectureTest {
return values;
});
return new ArchCondition<JavaClass>("not use the SQL function 'CURRENT_TIMESTAMP'") {
return new ArchCondition<>("not use the SQL function 'CURRENT_TIMESTAMP'") {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
for (JavaMethod method : javaClass.getAllMethods()) {

View File

@ -1,5 +1,6 @@
package acceptance.classification.create;
import static java.util.Objects.nonNull;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@ -66,7 +67,7 @@ class CreateClassificationAccTest {
classificationService.createClassificationQuery().keyIn("Key1").list();
assertThat(classifications)
.allMatch(c -> c.getId() != null)
.allMatch(c -> nonNull(c.getId()))
.usingRecursiveFieldByFieldElementComparatorIgnoringFields("id")
.containsExactlyInAnyOrder(
classification.asSummary(), expectedMasterClassification.asSummary());
@ -133,7 +134,7 @@ class CreateClassificationAccTest {
.list();
assertThat(classifications)
.allMatch(c -> c.getId() != null)
.allMatch(c -> nonNull(c.getId()))
.contains(childClassification.asSummary());
};

View File

@ -1,6 +1,7 @@
package acceptance.task.query;
import static java.lang.String.CASE_INSENSITIVE_ORDER;
import static java.util.Objects.nonNull;
import static org.assertj.core.api.Assertions.assertThat;
import static pro.taskana.common.api.BaseQuery.SortDirection.ASCENDING;
import static pro.taskana.common.api.BaseQuery.SortDirection.DESCENDING;
@ -392,7 +393,8 @@ class QueryTasksWithSortingAccTest extends AbstractAccTest {
.createTaskQuery()
.orderByOwnerLongName(DESCENDING)
.list();
assertThat(results.stream().filter(r -> r.getOwnerLongName() != null))
assertThat(results)
.filteredOn(r -> nonNull(r.getOwnerLongName()))
.hasSizeGreaterThan(2)
.extracting(TaskSummary::getOwnerLongName)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER.reversed());
@ -403,7 +405,8 @@ class QueryTasksWithSortingAccTest extends AbstractAccTest {
void should_OrderByOwnerLongNameAsc() {
List<TaskSummary> results =
taskanaEngine.getTaskService().createTaskQuery().orderByOwnerLongName(ASCENDING).list();
assertThat(results.stream().filter(r -> r.getOwnerLongName() != null))
assertThat(results)
.filteredOn(r -> nonNull(r.getOwnerLongName()))
.hasSizeGreaterThan(2)
.extracting(TaskSummary::getOwnerLongName)
.isSortedAccordingTo(CASE_INSENSITIVE_ORDER);

10
pom.xml
View File

@ -191,16 +191,6 @@
</plugins>
</build>
</profile>
<profile>
<id>jdk8-compatibility</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
<maven.compiler.testRelease>${java.version}</maven.compiler.testRelease>
</properties>
</profile>
<profile>
<id>snapshot</id>
<build>

View File

@ -1,5 +1,7 @@
package pro.taskana.common.rest;
import static java.util.function.Predicate.not;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
@ -228,7 +230,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
Set<String> enumConstantSet = new HashSet<>(enumConstants);
return getRejectedValues(typeMismatchException)
.filter(value -> !enumConstantSet.contains(value))
.filter(not(enumConstantSet::contains))
.map(value -> new MalformedQueryParameter(queryParameter, value, enumConstants))
.collect(Collectors.toList());
}

View File

@ -1,5 +1,7 @@
package pro.taskana.common.rest.ldap;
import static java.util.function.Predicate.not;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@ -565,18 +567,18 @@ public class LdapClient {
List<LdapSettings> checkForMissingConfigurations() {
return Arrays.stream(LdapSettings.values())
// optional settings
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_MAX_NUMBER_OF_RETURNED_ACCESS_IDS))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_MIN_SEARCH_FOR_LENGTH))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_EMAIL_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_PHONE_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_MOBILE_PHONE_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_1_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_2_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_3_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_4_ATTRIBUTE))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER_NAME))
.filter(p -> !p.equals(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER_TYPE))
.filter(not(LdapSettings.TASKANA_LDAP_MAX_NUMBER_OF_RETURNED_ACCESS_IDS::equals))
.filter(not(LdapSettings.TASKANA_LDAP_MIN_SEARCH_FOR_LENGTH::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_EMAIL_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_PHONE_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_MOBILE_PHONE_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_1_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_2_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_3_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_USER_ORG_LEVEL_4_ATTRIBUTE::equals))
.filter(not(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER::equals))
.filter(not(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER_NAME::equals))
.filter(not(LdapSettings.TASKANA_LDAP_GROUPS_OF_USER_TYPE::equals))
.filter(p -> p.getValueFromEnv(env) == null)
.collect(Collectors.toList());
}

View File

@ -1,7 +1,11 @@
package pro.taskana.task.rest;
import static java.util.function.Predicate.not;
import java.beans.ConstructorProperties;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
@ -130,9 +134,10 @@ public class TaskController {
BulkOperationResults<String, TaskanaException> result =
taskService.deleteTasks(taskIdsToDelete);
Set<String> failedIds = new HashSet<>(result.getFailedIds());
List<TaskSummary> successfullyDeletedTaskSummaries =
taskSummaries.stream()
.filter(summary -> !result.getFailedIds().contains(summary.getId()))
.filter(not(summary -> failedIds.contains(summary.getId())))
.collect(Collectors.toList());
return ResponseEntity.ok(

View File

@ -1,5 +1,6 @@
package pro.taskana.task.rest.assembler;
import static java.util.function.Predicate.not;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
@ -179,7 +180,8 @@ public class TaskRepresentationModelAssembler
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
task.setCallbackInfo(
repModel.getCallbackInfo().stream()
.filter(e -> Objects.nonNull(e.getKey()) && !e.getKey().isEmpty())
.filter(e -> Objects.nonNull(e.getKey()))
.filter(not(e -> e.getKey().isEmpty()))
.collect(Collectors.toMap(CustomAttribute::getKey, CustomAttribute::getValue)));
return task;
}

View File

@ -1,6 +1,7 @@
package pro.taskana;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static java.util.function.Predicate.not;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -36,12 +37,11 @@ class SpringArchitectureTest {
}
private ArchCondition<JavaClass> shouldOnlyHaveAnnotatedFields() {
return new ArchCondition<JavaClass>(
"all fields should have a @JsonProperty or @JsonIgnore annotation") {
return new ArchCondition<>("all fields should have a @JsonProperty or @JsonIgnore annotation") {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
javaClass.getAllFields().stream()
.filter(field -> !field.reflect().isSynthetic())
.filter(not(field -> field.reflect().isSynthetic()))
.filter(
field ->
Stream.of(JsonProperty.class, JsonIgnore.class)