code: public void addBeanRule(final BeanRule beanRule) throws IllegalRuleException {
          PrefixSuffixPattern prefixSuffixPattern = PrefixSuffixPattern.parse(beanRule.getId());
          String scanPattern = beanRule.getScanPattern();
          if (scanPattern != null) {
              BeanClassScanner scanner = createBeanClassScanner(beanRule);
              List<BeanRule> beanRules = new ArrayList<>();
              scanner.scan(scanPattern, (resourceName, targetClass) -> {
                  BeanRule beanRule2 = beanRule.replicate();
                  if (prefixSuffixPattern != null) {
                      beanRule2.setId(prefixSuffixPattern.join(resourceName));
                  } else {
                      if (beanRule.getId() != null) {
                          beanRule2.setId(beanRule.getId() + resourceName);
                      } else if (beanRule.getMaskPattern() != null) {
                          beanRule2.setId(resourceName);
                      }
                  }
                  beanRule2.setBeanClass(targetClass);
                  beanRules.add(beanRule2);
              });
              for (BeanRule beanRule2 : beanRules) {
                  dissectBeanRule(beanRule2);
              }
          } else {
              if (!beanRule.isFactoryOffered()) {
                  String className = beanRule.getClassName();
                  if (prefixSuffixPattern != null) {
                      beanRule.setId(prefixSuffixPattern.join(className));
                  }
                  Class<?> beanClass;
                  try {
                      beanClass = classLoader.loadClass(className);
                  } catch (ClassNotFoundException e) {
                      throw new BeanRuleException("Failed to load bean class", beanRule, e);
                  }
                  beanRule.setBeanClass(beanClass);
              }
              dissectBeanRule(beanRule);
          }
      }
docs: Adds a bean rule.
  
  @param beanRule the bean rule to add
  @throws IllegalRuleException if an error occurs while adding a bean rule