Source:
private Set<PersistentResource> getRelationUnchecked(String relationName, Optional<FilterExpression> filterExpression, boolean sortedAndPaginated) { RelationshipType type = getRelationshipType(relationName); final Class<?> relationClass = dictionary.getParameterizedType(obj, relationName); Optional<Pagination> pagination = Optional.ofNullable(requestScope.getPagination()); Optional<Sorting> sorting = Optional.ofNullable(requestScope.getSorting()); Optional<FilterExpression> permissionFilter = getPermissionFilterExpression(relationClass, requestScope); if (permissionFilter.isPresent() && filterExpression.isPresent()) { FilterExpression mergedExpression = new AndFilterExpression(filterExpression.get(), permissionFilter.get()); filterExpression = Optional.of(mergedExpression); } else if (permissionFilter.isPresent()) { filterExpression = permissionFilter; } Object val; if (requestScope.isMutatingMultipleEntities()) { val = transaction.getRelation(transaction, obj, relationName, Optional.empty(), sortedAndPaginated ? sorting : Optional.empty(), Optional.empty(), requestScope); } else { val = transaction.getRelation(transaction, obj, relationName, filterExpression, sortedAndPaginated ? sorting : Optional.empty(), sortedAndPaginated ? pagination.map(p -> p.evaluate(relationClass)) : Optional.empty(), requestScope); } if (val == null) { return Collections.emptySet(); } Set<PersistentResource> resources = Sets.newLinkedHashSet(); if (val instanceof Collection) { Collection filteredVal = (Collection) val; if (requestScope.isMutatingMultipleEntities()) { filteredVal = filterInMemory((Collection) val, filterExpression); } resources = new PersistentResourceSet(this, filteredVal, requestScope); } else if (type.isToOne()) { resources = new SingleElementSet( new PersistentResource(val, this, requestScope.getUUIDFor(val), requestScope)); } else { resources.add(new PersistentResource(val, this, requestScope.getUUIDFor(val), requestScope)); } return resources; }

Target:
private Set<PersistentResource> getRelationUnchecked(String relationName, Optional<FilterExpression> filterExpression, boolean sortedAndPaginated) { RelationshipType type = getRelationshipType(relationName); final Class<?> relationClass = dictionary.getParameterizedType(obj, relationName); Optional<Pagination> pagination = sortedAndPaginated ? Optional.ofNullable(requestScope.getPagination()).map(p -> p.evaluate(relationClass)) : Optional.empty(); Optional<Sorting> sorting = sortedAndPaginated ? Optional.ofNullable(requestScope.getSorting()) : Optional.empty(); Optional<FilterExpression> permissionFilter = getPermissionFilterExpression(relationClass, requestScope); if (permissionFilter.isPresent() && filterExpression.isPresent()) { FilterExpression mergedExpression = new AndFilterExpression(filterExpression.get(), permissionFilter.get()); filterExpression = Optional.of(mergedExpression); } else if (permissionFilter.isPresent()) { filterExpression = permissionFilter; } Object val; if (requestScope.isMutatingMultipleEntities()) { val = transaction.getRelation(transaction, obj, relationName, Optional.empty(), sorting, Optional.empty(), requestScope); if (val instanceof Collection) { val = filterInMemory((Collection) val, filterExpression); } } else { val = transaction.getRelation(transaction, obj, relationName, filterExpression, sorting, pagination, requestScope); } if (val == null) { return Collections.emptySet(); } Set<PersistentResource> resources = Sets.newLinkedHashSet(); if (val instanceof Collection) { Collection filteredVal = (Collection) val; resources = new PersistentResourceSet(this, filteredVal, requestScope); } else if (type.isToOne()) { resources = new SingleElementSet( new PersistentResource(val, this, requestScope.getUUIDFor(val), requestScope)); } else { resources.add(new PersistentResource(val, this, requestScope.getUUIDFor(val), requestScope)); } return resources; }