Package org.symbol.sdk
Class RuleBasedTransactionFactory
java.lang.Object
org.symbol.sdk.RuleBasedTransactionFactory
- RuleBasedTransactionFactory
- Rule-based transaction factory: registers named parsing rules (POD / enum / flags / struct / array) and applies them via
TransactionDescriptorProcessor. Rules come from the generatedModels.POD_FACTORIESregistry and typed struct suppliers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a rule-based transaction factory without a custom type converter or overrides.RuleBasedTransactionFactory(Function<Object, Object> typeConverter, Map<String, Function<Object, Object>> typeRuleOverrides) Creates a rule-based transaction factory for use with catbuffer generated code. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArrayParser(String name) Creates an array type parser based on an existing element type parser.voidaddPodParser(String name, Function<Object, Object> parser) Registers a parser for a POD type.voidRegisters a batch of named value-parse rules — typically a generatedModels.POD_FACTORIESregistry.voidaddStructParser(String name, Supplier<? extends CatbufferType> factory) Creates a struct parser (allows nested parsing) over a strongly typed factory reference.Creates an entity from a descriptor using a factory.
-
Field Details
-
rules
Map of rule names to transform functions
-
-
Constructor Details
-
RuleBasedTransactionFactory
public RuleBasedTransactionFactory(Function<Object, Object> typeConverter, Map<String, Function<Object, Object>> typeRuleOverrides) Creates a rule-based transaction factory for use with catbuffer generated code.- Parameters:
typeConverter- Optional convert to a more appropriate type.typeRuleOverrides- Per-rule parser overrides keyed by rule name.
-
RuleBasedTransactionFactory
public RuleBasedTransactionFactory()Creates a rule-based transaction factory without a custom type converter or overrides.
-
-
Method Details
-
addPodParsers
- RuleBasedTransactionFactory.addPodParsers
- Registers a batch of named value-parse rules — typically a generated
Models.POD_FACTORIESregistry.
- Parameters:
parsers- Rule name → parse function.
-
addPodParser
- RuleBasedTransactionFactory.addPodParser
- Registers a parser for a POD type. The parser is replaced by a matching
typeRuleOverridesentry when one was supplied forname.
- Parameters:
name- Rule name (and override key).parser- Parse function converting a raw descriptor value into the POD.
-
addStructParser
- RuleBasedTransactionFactory.addStructParser
- Creates a struct parser (allows nested parsing) over a strongly typed factory reference.
- Parameters:
name- Class name (rule key).factory- Supplier producing a fresh, default-initialized struct instance.
-
addArrayParser
- RuleBasedTransactionFactory.addArrayParser
- Creates an array type parser based on an existing element type parser.
- Parameters:
name- Class name (existing rule key).
-
createFromFactory
- RuleBasedTransactionFactory.createFromFactory
- Creates an entity from a descriptor using a factory. The descriptor's required
typekey selects the entity; remaining keys are copied onto it throughTransactionDescriptorProcessor.copyTo(org.symbol.sdk.CatbufferType, java.util.List<java.lang.String>).
- Parameters:
factory- Function that, given the resolvedtypevalue, returns a new entity.descriptor- Entity descriptor.- Returns:
- Newly created entity.
-