Skip to content

Commit

Permalink
feat: changed the tracker for a more generic class
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlen committed Jan 9, 2025
1 parent 3efcf62 commit 57822e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ public Federation getOldFederation(FederationConstants federationConstants, Acti
}
);

oldFederationTracker.set(oldFederation, false);
oldFederationTracker.set(oldFederation);
return oldFederationTracker.get();
}

@Override
public void setOldFederation(Federation federation) {
oldFederationTracker.set(federation, true);
oldFederationTracker.setNew(federation);
}

@Override
Expand All @@ -190,13 +190,13 @@ public PendingFederation getPendingFederation() {
}
);

pendingFederationTracker.set(pendingFederation, false);
pendingFederationTracker.set(pendingFederation);
return pendingFederationTracker.get();
}

@Override
public void setPendingFederation(PendingFederation federation) {
pendingFederationTracker.set(federation, true);
pendingFederationTracker.setNew(federation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
package co.rsk.peg.federation;

public class FederationTracker<T> {
private T federation;
private T value;
private boolean modified = false;

public boolean isModified() {
return this.modified;
}

public T get() {
return this.federation;
return this.value;
}

public boolean isPresent() {
return this.federation != null;
return this.value != null;
}

public boolean hasBeenSet() {
return this.isPresent() || this.isModified();
}

public void set(T aFederation, boolean shouldSave) {
this.federation = aFederation;
this.modified = shouldSave;
public void setNew(T aValue) {
this.value = aValue;
this.modified = true;
}

public void set(T aValue) {
this.value = aValue;
}
}

0 comments on commit 57822e0

Please sign in to comment.