Skip to content

Commit

Permalink
Merge pull request #1181 from dragos/fix/default-external-hooks
Browse files Browse the repository at this point in the history
Fix DefaultExternalHooks copy methods
  • Loading branch information
eed3si9n authored Apr 19, 2023
2 parents 6ce25cd + c071d34 commit 5a429ce
Showing 1 changed file with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ public class DefaultExternalHooks implements ExternalHooks {
private Optional<ExternalHooks.Lookup> lookup = Optional.empty();
private Optional<ClassFileManager> classFileManager = Optional.empty();
private GetProvenance getProvenance = NoProvenance.INSTANCE;
private InvalidationProfiler invalidationProfiler = InvalidationProfiler.EMPTY.INSTANCE;

public DefaultExternalHooks(
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance,
InvalidationProfiler invalidationProfiler
) {
this.lookup = lookup;
this.classFileManager = classFileManager;
this.getProvenance = getProvenance;
this.invalidationProfiler = invalidationProfiler;
}
public DefaultExternalHooks(
Optional<ExternalHooks.Lookup> lookup,
Optional<ClassFileManager> classFileManager,
GetProvenance getProvenance
) {
this(lookup, classFileManager, getProvenance, InvalidationProfiler.EMPTY.INSTANCE);
}

public DefaultExternalHooks(Optional<ExternalHooks.Lookup> lookup, Optional<ClassFileManager> classFileManager) {
Expand All @@ -44,23 +54,31 @@ public Optional<ClassFileManager> getExternalClassFileManager() {

@Override public GetProvenance getProvenance() { return getProvenance; }

@Override
public InvalidationProfiler getInvalidationProfiler() { return invalidationProfiler; }

@Override
public ExternalHooks withExternalClassFileManager(ClassFileManager externalClassFileManager) {
Optional<ClassFileManager> external = Optional.of(externalClassFileManager);
Optional<ClassFileManager> mixedManager = classFileManager.isPresent()
? Optional.of(WrappedClassFileManager.of(classFileManager.get(), external))
: external;
return new DefaultExternalHooks(lookup, mixedManager, getProvenance);
return new DefaultExternalHooks(lookup, mixedManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withExternalLookup(ExternalHooks.Lookup externalLookup) {
Optional<Lookup> externalLookup1 = Optional.of(externalLookup);
return new DefaultExternalHooks(externalLookup1, classFileManager, getProvenance);
return new DefaultExternalHooks(externalLookup1, classFileManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withGetProvenance(GetProvenance getProvenance) {
return new DefaultExternalHooks(lookup, classFileManager, getProvenance);
return new DefaultExternalHooks(lookup, classFileManager, getProvenance, invalidationProfiler);
}

@Override
public ExternalHooks withInvalidationProfiler(InvalidationProfiler profiler) {
return new DefaultExternalHooks(lookup, classFileManager, getProvenance, profiler);
}
}

0 comments on commit 5a429ce

Please sign in to comment.