code: private void rebuildAlternates() {
      UnionTypeBuilder builder = UnionTypeBuilder.create(registry);
      builder.addAlternates(alternates);
      alternates = builder.getAlternates();
    }
docs: Use UnionTypeBuilder to rebuild the list of alternates and hashcode of the current UnionType.