Add 'better' natural order for sorting VESID based on ID (and maybe on Display name as well)
Closed this issue · 6 comments
The version 3.10.1 is 'lower' then 3.9 when sorted in ExtValidationKeyRegistry
as it currently is, it is even lower than 3.2.0 so they display order is sort of off. Both when sorted by ID and DisplayName.
Using Something like https://github.com/paour/natorder/blob/master/NaturalOrderComparator.java makes it work for ID's. Not sure what to do with the display name that also uses the locale in there
How did you try it? For the ID's it is simple, for the DisplayName I cannot get anything compiled. Messing with the IComparator
and IHasDisplayName
even... and still nothing
In IComparator
I added this:
@Nonnull
static <T> Comparator <T> getComparatorNaturalOrder (@Nonnull final Function <? super T, String> aMapper)
{
return Comparator.<T, String> comparing (aMapper, new NaturalOrderComparator());
}
And in IHasDisplayName
I changed this:
@Nonnull
static Comparator <IHasDisplayName> getComparatorNaturalOrder(@Nullable final Locale aSortLocale)
{
return IComparator.getComparatorNaturalOrder(IHasDisplayName::getDisplayName);
}
And in ExtValidationKeyRegistry#getAllSortedByDisplayName
I did this:
return aMap.getSortedByValue (IHasDisplayName.getComparatorNaturalOrder(aDisplayLocale));
I know it is not all in the correct way/location but it does work. Unfortunately (or not) it is not using the locale anymore, but since there are limited locales in this displayName, it might be fine.
Maybe it helps fitting things better in your classes
9For quick testing I copied all classes to the phase4-peppol-client)
1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:despatch-advice:3.12.0, OpenPEPPOL Despatch Advice (3.12.0) (aka BIS 3.0.7), [GroupID=eu.peppol.bis3; ArtifactID=despatch-advice; Version=3.12.0] 1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.5.0, OpenPEPPOL Invoice (3.5.0) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.5.0] 1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.6.0, OpenPEPPOL Invoice (3.6.0) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.6.0] 1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:3.7.0, OpenPEPPOL Invoice (3.7.0) (aka BIS 2) (deprecated!), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=3.7.0] 1910 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.8.0, OpenPEPPOL Invoice (3.8.0) (aka BIS Billing 3.0.3) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.8.0] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.8.1, OpenPEPPOL Invoice (3.8.1) (aka BIS Billing 3.0.4) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.8.1] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.9.0, OpenPEPPOL Invoice (3.9.0) (aka BIS Billing 3.0.5) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.9.0] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.9.1, OpenPEPPOL Invoice (3.9.1) (aka BIS Billing 3.0.5 + Hotfix) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.9.1] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.10.0, OpenPEPPOL Invoice (3.10.0) (aka BIS Billing 3.0.6) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.10.0] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.10.1, OpenPEPPOL Invoice (3.10.1) (aka BIS Billing 3.0.7) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.10.1] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.11.0, OpenPEPPOL Invoice (3.11.0) (aka BIS Billing 3.0.8) (deprecated!), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.11.0] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.11.1, OpenPEPPOL Invoice (3.11.1) (aka BIS Billing 3.0.9), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.11.1] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis3:invoice:3.12.0, OpenPEPPOL Invoice (3.12.0) (aka BIS Billing 3.0.10), [GroupID=eu.peppol.bis3; ArtifactID=invoice; Version=3.12.0] 1911 [main] INFO com.helger.phase4.peppol.MainPhase4PeppolSender - eu.peppol.bis2:t10:6:at, OpenPEPPOL Invoice (Austria), [GroupID=eu.peppol.bis2; ArtifactID=t10; Version=6; Classifier=at]
it DOES use the comparator that I linked too... That does exactly that, split/use numbers as numbers
Finally made it work - thanks!