Class RuleBasedTransactionFactory

java.lang.Object
org.symbol.sdk.RuleBasedTransactionFactory

public final class RuleBasedTransactionFactory extends Object
RuleBasedTransactionFactory

Rule-based transaction factory: registers named parsing rules (POD / enum / flags / struct / array) and applies them via TransactionDescriptorProcessor. Rules come from the generated Models.POD_FACTORIES registry and typed struct suppliers.

  • Field Details

  • 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

      public void addPodParsers(Map<String,Function<Object,Object>> parsers)
      RuleBasedTransactionFactory.addPodParsers

      Registers a batch of named value-parse rules — typically a generated Models.POD_FACTORIES registry.

      Parameters:

      parsers - Rule name → parse function.

    • addPodParser

      public void addPodParser(String name, Function<Object,Object> parser)
      RuleBasedTransactionFactory.addPodParser

      Registers a parser for a POD type. The parser is replaced by a matching typeRuleOverrides entry when one was supplied for name.

      Parameters:

      name - Rule name (and override key).

      parser - Parse function converting a raw descriptor value into the POD.

    • addStructParser

      public void addStructParser(String name, Supplier<? extends CatbufferType> factory)
      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

      public void addArrayParser(String name)
      RuleBasedTransactionFactory.addArrayParser

      Creates an array type parser based on an existing element type parser.

      Parameters:

      name - Class name (existing rule key).

    • createFromFactory

      public Object createFromFactory(Function<Object,Object> factory, Map<String,Object> descriptor)
      RuleBasedTransactionFactory.createFromFactory

      Creates an entity from a descriptor using a factory. The descriptor's required type key selects the entity; remaining keys are copied onto it through TransactionDescriptorProcessor.copyTo(org.symbol.sdk.CatbufferType, java.util.List<java.lang.String>).

      Parameters:

      factory - Function that, given the resolved type value, returns a new entity.

      descriptor - Entity descriptor.

      Returns:

      Newly created entity.