class SimpleCatalogUtilsService implements CatalogUtilsService {

    @Override
    public void addChanges(Resource targetNamedGraph, Resource oppositeNamedGraph, Model changes,
                           RepositoryConnection conn) {
        if (changes == null) {
            return;
        }

        Set<Statement> oppositeGraphStatements = RepositoryResults.asSet(conn.getStatements(null,
                null, null, oppositeNamedGraph));

        changes.forEach(statement -> {
            Statement withContext = vf.createStatement(statement.getSubject(), statement.getPredicate(),
                    statement.getObject(), oppositeNamedGraph);
            if (!oppositeGraphStatements.contains(withContext)) {
                conn.add(statement, targetNamedGraph);
            } else {
                conn.remove(withContext, oppositeNamedGraph);
                oppositeGraphStatements.remove(withContext);
            }
        });
    }

}