Skip to content

Commit

Permalink
chore!(servient): remove hasClientFor method
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 12, 2024
1 parent f252675 commit 0fd933f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
4 changes: 0 additions & 4 deletions lib/src/core/implementation/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class ConsumedThing implements scripting_api.ConsumedThing {
/// Determines the id of this [ConsumedThing].
String get identifier => thingDescription.identifier;

/// Checks if the [Servient] of this [ConsumedThing] supports a protocol
/// [scheme].
bool hasClientFor(String scheme) => servient.hasClientFor(scheme);

(ProtocolClient client, AugmentedForm form) _getClientFor(
List<Form> forms,
OperationType operationType,
Expand Down
3 changes: 0 additions & 3 deletions lib/src/core/implementation/servient.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,6 @@ class Servient {
ProtocolClientFactory? removeClientFactory(String scheme) =>
_clientFactories.remove(scheme);

/// Checks whether a [ProtocolClient] is avaiable for a given [scheme].
bool hasClientFor(String scheme) => _clientFactories.containsKey(scheme);

/// Returns the [ProtocolClient] associated with a given [scheme].
ProtocolClient clientFor(String scheme) {
final clientFactory = _clientFactories[scheme];
Expand Down
8 changes: 2 additions & 6 deletions lib/src/core/implementation/thing_discovery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,9 @@ class ThingDiscovery extends Stream<ThingDescription>

ProtocolClient _clientForUriScheme(Uri uri) {
final uriScheme = uri.scheme;
var client = _clients[uriScheme];

if (client == null) {
client = _servient.clientFor(uriScheme);
_clients[uriScheme] = client;
}
final client = _clients[uriScheme] ?? _servient.clientFor(uriScheme);

_clients[uriScheme] = client;
return client;
}

Expand Down
5 changes: 2 additions & 3 deletions test/core/servient_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void main() {
);

expect(servient.clientSchemes, [testUriScheme]);
expect(servient.hasClientFor(testUriScheme), true);
});

test(
Expand All @@ -53,11 +52,11 @@ void main() {
final servient = Servient()
..addClientFactory(MockedProtocolClientFactory());

expect(servient.hasClientFor(testUriScheme), true);
expect(servient.clientSchemes.contains(testUriScheme), true);

servient.removeClientFactory(testUriScheme);

expect(servient.hasClientFor(testUriScheme), false);
expect(servient.clientSchemes.contains(testUriScheme), false);
expect(servient.clientSchemes.length, 0);
},
);
Expand Down

0 comments on commit 0fd933f

Please sign in to comment.