Package org.osgi.util.converter
Class ConverterBuilderImpl
java.lang.Object
org.osgi.util.converter.ConverterBuilderImpl
- All Implemented Interfaces:
ConverterBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List
<ConverterFunction> private final InternalConverter
private final List
<ConverterFunction> private final Map
<Type, List<ConverterFunction>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the specified converter.Register a custom error handler.private List
<ConverterFunction> getRulesList
(Type type) rule
(Type t, ConverterFunction func) Register a conversion rule for this converter.rule
(ConverterFunction func) Register a catch-all rule, will be called of no other rule matches.rule
(TargetRule rule) Register a conversion rule for this converter.
-
Field Details
-
converter
-
rules
-
catchAllRules
-
errorHandlers
-
-
Constructor Details
-
ConverterBuilderImpl
-
-
Method Details
-
build
Description copied from interface:ConverterBuilder
Build the specified converter. Each time this method is called a new custom converter is produced based on the rules registered with the builder.- Specified by:
build
in interfaceConverterBuilder
- Returns:
- A new converter with the rules provided to the builder.
-
errorHandler
Description copied from interface:ConverterBuilder
Register a custom error handler. The custom error handler will be called when the conversion would otherwise throw an exception. The error handler can either throw a different exception or return a value to be used for the failed conversion.- Specified by:
errorHandler
in interfaceConverterBuilder
- Parameters:
func
- The function to be used to handle errors.- Returns:
- This converter builder for further building.
-
rule
Description copied from interface:ConverterBuilder
Register a catch-all rule, will be called of no other rule matches.- Specified by:
rule
in interfaceConverterBuilder
- Parameters:
func
- The function that will handle the conversion.- Returns:
- This converter builder for further building.
-
rule
Description copied from interface:ConverterBuilder
Register a conversion rule for this converter. Note that only the target type is specified, so the rule will be visited for every conversion to the target type.- Specified by:
rule
in interfaceConverterBuilder
- Parameters:
t
- The type that this rule will produce.func
- The function that will handle the conversion.- Returns:
- This converter builder for further building.
-
rule
Description copied from interface:ConverterBuilder
Register a conversion rule for this converter.- Specified by:
rule
in interfaceConverterBuilder
- Parameters:
rule
- A rule implementation.- Returns:
- This converter builder for further building.
-
getRulesList
-