Package org.pipservices3.commons.config
Class NameResolver
java.lang.Object
org.pipservices3.commons.config.NameResolver
A helper class that allows to extract component name from configuration parameters.
The name can be defined in
"id"
, "name"
parameters or inside a component descriptor.
### Example ###
ConfigParams config = ConfigParams.fromTuples(
"descriptor", "myservice:connector:aws:connector1:1.0",
"param1", "ABC",
"param2", 123
);
String name = NameResolver.resolve(config); // Result: connector1
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
resolve
(ConfigParams config, String defaultName) Resolves a component name from configuration parameters.
-
Constructor Details
-
NameResolver
public NameResolver()
-
-
Method Details
-
resolve
Resolves a component name from configuration parameters. The name can be stored in "id", "name" fields or inside a component descriptor. If name cannot be determined it returns a defaultName.- Parameters:
config
- configuration parameters that may contain a component name.defaultName
- (optional) a default component name.- Returns:
- resolved name or default name if the name cannot be determined.
-