Record Class ProviderScore
- Record Components:
provider- the provider this score belongs to; nevernullscore- the SPI Priority Score returned byAudioSourceProvider.canOpen(java.nio.file.Path): an integer in[0, 100]when the provider is applicable, or-1when it declined (including the case wherecanOpenthrew anIOExceptionthatAudioSourcescaught and logged per Requirement 5.9)priority- the value ofAudioSourceProvider.priority()at the time of scoring, used as the tie-breaker when two providers return the samescore
AudioSourceProvider during the
content-based dispatch performed by AudioSources.open(...). Pairs
a provider with the SPI Priority Score it returned from
AudioSourceProvider.canOpen(java.nio.file.Path) and the priority() value captured at scoring time
so the tie-break (Requirement 5.6) is decided from a single, consistent
snapshot.
Extracting this tuple keeps AudioSources's scoring loop
readable: the facade collects one ProviderScore per provider it
consults, filters out the non-applicable ones (score < 0), and
picks the winner with
java.util.Collections.max(eligible, BY_SCORE_THEN_PRIORITY). The
full list of ProviderScores also feeds the diagnostic population
on UnsupportedAudioFormatException (Requirements 6.4, 6.5, 6.6)
when every provider returned -1.
This class is not part of the published API. It
lives in com.tino1b2be.dtmf.io.internal, whose stability
contract (see the package Javadoc) explicitly allows breakage between
any two releases. It is public at the type level purely so
AudioSources — which lives in the parent package and
cannot otherwise see a package-private type here — can reach it;
external callers MUST NOT depend on it.
- Since:
- 2.1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<ProviderScore>Ordering used to pick the winning provider during dispatch (Requirement 5.6). -
Constructor Summary
ConstructorsConstructorDescriptionProviderScore(AudioSourceProvider provider, int score, int priority) Compact constructor enforcing thatprovideris non-null. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intpriority()Returns the value of thepriorityrecord component.provider()Returns the value of theproviderrecord component.intscore()Returns the value of thescorerecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
BY_SCORE_THEN_PRIORITY
Ordering used to pick the winning provider during dispatch (Requirement 5.6). Orders ascending first byscore()and then, on ties, ascending bypriority()— so the greatest pair under this ordering is the provider that returned the strictly greatest SPI Priority Score, tie-broken by the greatestpriority()value.Typical use in
AudioSources:ProviderScore winner = Collections.max(eligible, ProviderScore.BY_SCORE_THEN_PRIORITY);When two
ProviderScores are equal under bothscoreandpriority, the comparator returns zero; in that caseAudioSourcespicks the earlier entry in discovery order simply becauseCollections.maxreturns the last maximal element while the scoring loop encounters the providers in discovery order — but the whole system does not depend on which way that coin lands, since two providers genuinely indistinguishable by this ordering are, by construction, equally valid choices.
-
-
Constructor Details
-
ProviderScore
Compact constructor enforcing thatprovideris non-null.- Throws:
NullPointerException- ifproviderisnull
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
provider
Returns the value of theproviderrecord component.- Returns:
- the value of the
providerrecord component
-
score
public int score()Returns the value of thescorerecord component.- Returns:
- the value of the
scorerecord component
-
priority
public int priority()Returns the value of thepriorityrecord component.- Returns:
- the value of the
priorityrecord component
-