Module replacement rules in java

I am trying to use the module replacement rules in a java plugin. I can’t seem to figure out how to get access to the ComponentModuleMetadataDetails.replacedBy(). I was thinking I could do

getDependencies().getModules().module("com.google.collections:google-collections", new Action<ComponentModuleMetadataDetails>() {
      @Override
      public void execute(ComponentModuleMetadataDetails componentModuleMetadata) {
        componentModuleMetadata.replacedBy("'com.google.guava:guava");
      }
});

I feel like I’m missing something obvious. Any ideas?

The Action<T> in the case takes a ComponentModuleMetadata so you’ll have to cast it to ComponentModuleMetadataDetails to call replacedBy().

getDependencies().getModules().module("com.google.collections:google-collections", new Action<ComponentModuleMetadata>() {
  @Override
  public void execute(ComponentModuleMetadata componentModuleMetadata) {
    ((ComponentModuleMetadataDetails)componentModuleMetadata).replacedBy("com.google.guava:guava");
  }
});

Will the action always be called with a ComponentModuleMetadataDetails? If so would it make since to change the signature to be ComponentModuleMetadataDetails?

@daz can you weight in here? Does it make sense to change the type of the Action<T> in this case? Is this a safe cast to make?