Small refactor to reduce code duplication.

This commit is contained in:
CalDescent 2021-12-22 17:03:54 +00:00
parent 87b724ec72
commit 19173321ea

View File

@ -93,9 +93,7 @@ public class ArbitraryDataReader {
public boolean isCachedDataAvailable() { public boolean isCachedDataAvailable() {
// If this resource is in the build queue then we shouldn't attempt to serve // If this resource is in the build queue then we shouldn't attempt to serve
// cached data, as it may not be fully built // cached data, as it may not be fully built
ArbitraryDataBuildQueueItem queueItem = if (ArbitraryDataBuildManager.getInstance().isInBuildQueue(this.createQueueItem())) {
new ArbitraryDataBuildQueueItem(this.resourceId, this.resourceIdType, this.service, this.identifier);
if (ArbitraryDataBuildManager.getInstance().isInBuildQueue(queueItem)) {
return false; return false;
} }
@ -109,6 +107,10 @@ public class ArbitraryDataReader {
return false; return false;
} }
private ArbitraryDataBuildQueueItem createQueueItem() {
return new ArbitraryDataBuildQueueItem(this.resourceId, this.resourceIdType, this.service, this.identifier);
}
/** /**
* loadAsynchronously * loadAsynchronously
* *
@ -119,9 +121,7 @@ public class ArbitraryDataReader {
* @return true if added or already present in queue; false if not * @return true if added or already present in queue; false if not
*/ */
public boolean loadAsynchronously() { public boolean loadAsynchronously() {
ArbitraryDataBuildQueueItem queueItem = return ArbitraryDataBuildManager.getInstance().addToBuildQueue(this.createQueueItem());
new ArbitraryDataBuildQueueItem(this.resourceId, this.resourceIdType, this.service, this.identifier);
return ArbitraryDataBuildManager.getInstance().addToBuildQueue(queueItem);
} }
/** /**