improved anonymization
This commit is contained in:
@@ -35,21 +35,16 @@ public class JodelPost {
|
||||
public Optional<Long> parent = Optional.empty();
|
||||
|
||||
// anonymize function to recursively anonymize the posts
|
||||
public void anonymize(Optional<Vector<Long>> idCache) {
|
||||
// check if this is the first post in this process
|
||||
if (idCache.isEmpty()) {
|
||||
// create a new Vector as cache
|
||||
idCache = Optional.of(new Vector<>());
|
||||
}
|
||||
public void anonymize(Vector<Long> idCache) {
|
||||
|
||||
// get the anonymized id as index in cached authorIDs
|
||||
int i = idCache.get().indexOf(this.authorID);
|
||||
int i = idCache.indexOf(this.authorID);
|
||||
// if the index is -1 the authorID has not been cached jet
|
||||
if (i == -1) {
|
||||
// set the current anonymousID as length of the cache (== next index)
|
||||
this.anonymousID = (long) idCache.get().size();
|
||||
this.anonymousID = (long) idCache.size();
|
||||
// push the current authorID to to cache
|
||||
idCache.get().add(this.authorID);
|
||||
idCache.add(this.authorID);
|
||||
}
|
||||
// the authorID has been anonymized once before, so we can get it from cache
|
||||
else this.anonymousID = (long) i;
|
||||
|
||||
Reference in New Issue
Block a user