Skip to content

Commit

Permalink
Cleanup source implementations, and properly cache URI-based sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Jun 26, 2024
1 parent 44a6cd1 commit 61f3303
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 91 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ public final class ExternalSource implements ISource {
public static ISource instance(@NonNull URI location) {
ISource retval;
synchronized (sources) {
retval = sources.get(location);
if (retval == null) {
retval = new ExternalModelSource(location);
}
retval = sources.computeIfAbsent(location, (uri) -> new ExternalSource(uri));
}
return retval;
}
Expand All @@ -80,4 +77,9 @@ public SourceType getSourceType() {
public URI getSource() {
return modelUri;
}

@Override
public String toString() {
return "external:" + modelUri;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public final class InternalModelSource implements ISource {
@NonNull
private static final Map<URI, ExternalModelSource> sources = new HashMap<>(); // NOPMD - intentional
private static final Map<URI, InternalModelSource> sources = new HashMap<>(); // NOPMD - intentional
@NonNull
private final URI modelUri;

Expand All @@ -57,10 +57,7 @@ public final class InternalModelSource implements ISource {
public static ISource instance(@NonNull URI location) {
ISource retval;
synchronized (sources) {
retval = sources.get(location);
if (retval == null) {
retval = new InternalModelSource(location);
}
retval = sources.computeIfAbsent(location, (uri) -> new InternalModelSource(uri));
}
return retval;
}
Expand All @@ -79,4 +76,9 @@ public SourceType getSourceType() {
public URI getSource() {
return modelUri;
}

@Override
public String toString() {
return "internal:" + modelUri;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,9 @@ public URI getSource() {
// always null
return null;
}

@Override
public String toString() {
return "internal";
}
}

0 comments on commit 61f3303

Please sign in to comment.