Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Shardingsphere YamlRuleConfigurationReflectionEngine Reflect

From Leeroopedia


Knowledge Sources
Domains Mode_Management, Reflection
Last Updated 2026-02-10 00:00 GMT

Overview

YamlRuleConfigurationReflectionEngine provides reflection utilities for extracting annotated fields and deriving registry node item names from YAML rule configuration classes.

Description

YamlRuleConfigurationReflectionEngine is a utility class with a private constructor that offers three static methods. findClass locates a YamlRuleConfiguration class by its rule type string by scanning all SPI-loaded YamlRuleConfigurationSwapper instances and matching the @RuleNodeTupleEntity annotation value. getFields returns the declared fields of a YAML rule config class that are annotated with @RuleNodeTupleField, sorted by the field type ordinal. getRuleNodeItemName converts a Java field name from lowerCamel to lower_underscore format using Guava's CaseFormat.

Usage

Use this engine when you need to discover YAML rule configuration classes by rule type, enumerate their annotated fields in order, or convert field names to registry node path segments. It is used by DatabaseRuleNodeGenerator and YamlRuleNodeTupleSwapperEngine.

Code Reference

Source Location

Signature

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class YamlRuleConfigurationReflectionEngine {

    public static Class<? extends YamlRuleConfiguration> findClass(final String ruleType)

    public static Collection<Field> getFields(
            final Class<? extends YamlRuleConfiguration> yamlRuleConfigClass)

    public static String getRuleNodeItemName(final Field field)
}

Import

import org.apache.shardingsphere.mode.node.rule.tuple.YamlRuleConfigurationReflectionEngine;

I/O Contract

Inputs

Name Type Required Description
ruleType String Yes Rule type identifier (e.g., "sharding") to find the class
yamlRuleConfigClass Class<? extends YamlRuleConfiguration> Yes Class to extract fields from
field Field Yes Java reflection field to convert to node item name

Outputs

Name Type Description
yamlRuleConfigClass Class<? extends YamlRuleConfiguration> The located YAML configuration class
fields Collection<Field> Annotated fields sorted by type ordinal
ruleNodeItemName String Lower-underscore formatted name (e.g., "sharding_algorithms")

Usage Examples

// Find YAML rule configuration class by rule type
Class<? extends YamlRuleConfiguration> clazz =
    YamlRuleConfigurationReflectionEngine.findClass("sharding");

// Get annotated fields
Collection<Field> fields = YamlRuleConfigurationReflectionEngine.getFields(clazz);

// Convert field name to registry node item name
String itemName = YamlRuleConfigurationReflectionEngine.getRuleNodeItemName(field);
// "shardingAlgorithms" -> "sharding_algorithms"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment