Descriptor class
Locator type that most often used in PipServices toolkit. It locates components using several fields:
- Group: a package or just named group of components like 'pip-services'
- Type: logical component type that defines it's contract like 'persistence'
- Kind: physical implementation type like 'mongodb'
- Name: unique component name like 'default'
- Version: version of the component contract like '1.0'
The locator matching can be done by all or only few selected fields.
The fields that shall be excluded from the matching must be set to '*'
or null
.
That approach allows to implement many interesting scenarios. For instance:
- Locate all loggers (match by type and version)
- Locate persistence components for a microservice (match by group and type)
- Locate specific component by its name (match by name)
Example
var locator1 = Descriptor('mygroup', 'connector', 'aws', 'default', '1.0');
var locator2 = Descriptor.fromString('mygroup:connector:*:*:1.0');
locator1.match(locator2); // Result: true
locator1.equal(locator2); // Result: true
locator1.exactMatch(locator2); // Result: false
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
equals(
dynamic value) → bool - Compares this descriptor to a value. If value is a Descriptor it tries to match them, otherwise the method returns false.
-
exactMatch(
Descriptor descriptor) → bool - Matches this descriptor to another descriptor by all fields. No exceptions are made.
-
getGroup(
) → String? - Gets the component's logical group.
-
getKind(
) → String? - Gets the component's implementation type.
-
getName(
) → String? - Gets the unique component's name.
-
getType(
) → String? - Gets the component's logical type.
-
getVersion(
) → String? - Gets the component's implementation version.
-
isComplete(
) → bool - Checks whether all descriptor fields are set. If descriptor has at least one '*' or null field it is considered 'incomplete',
-
match(
Descriptor descriptor) → bool - Partially matches this descriptor to another descriptor. Fields that contain '*' or null are excluded from the match.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Gets a string representation of the object.
The result is a colon-separated list of descriptor fields as
'mygroup:connector:aws:default:1.0'
override
Operators
-
operator ==(
Object value) → bool -
The equality operator.
override
Static Methods
-
fromString(
String? value) → Descriptor? - Parses colon-separated list of descriptor fields and returns them as a Descriptor.