Record Class ProductResolver
java.lang.Object
java.lang.Record
io.github.dinethdilhara.urltoproduct.engine.ProductResolver
ProductResolver
Responsible for selecting the appropriate ProductProvider
based on the given URL.
This class uses a simple strategy: it finds the first provider
that supports the given URL. If no provider matches, an
UnsupportedUrlException is thrown.
ProductProvider provider = resolver.resolve("https://example.com/product/123");
- Version:
- 1.0.0
- Author:
- Dineth Dilhara
-
Constructor Summary
ConstructorsConstructorDescriptionProductResolver(List<ProductProvider> providers) Creates an instance of aProductResolverrecord class. -
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.Returns the value of theprovidersrecord component.Resolves the appropriate provider for the given URL.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ProductResolver
Creates an instance of aProductResolverrecord class.- Parameters:
providers- the value for theprovidersrecord component
-
-
Method Details
-
resolve
Resolves the appropriate provider for the given URL.- Parameters:
url- product URL- Returns:
- matching ProductProvider
- Throws:
UnsupportedUrlException- if no provider supports the URL
-
toString
-
hashCode
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
providers
Returns the value of theprovidersrecord component.- Returns:
- the value of the
providersrecord component
-