This repository has been archived by the owner on Jun 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.epita.guereza; | ||
|
||
import com.epita.domain.Document; | ||
import com.epita.domain.Index; | ||
import com.epita.guereza.eventsourcing.Event; | ||
import com.epita.guereza.eventsourcing.Reducer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class RetroIndex implements Reducer { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(RetroIndex.class); | ||
|
||
private final Index index = new Index(); | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void reduce(final Event<?> event) { | ||
switch (event.type) { | ||
case "ADD_DOCUMENT": | ||
addDocument((Event<Document>) event); | ||
break; | ||
} | ||
} | ||
|
||
private void addDocument(Event<Document> event) { | ||
index.docs.add(event.obj); | ||
LOGGER.info("added a document to the index"); | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.