private void changeRules(Rules rules) {
    instance.rules = rules;
    instance.preBmBc = BoyerMoore.preBmBc(rules);
    instance.preBmGs = BoyerMoore.preBmGs(rules);
    instance.suffixes = BoyerMoore.suffixes(rules);

    preSkip = new HashMap<>();

    rules.forEach(
        rule -> {
          preSkip.put(rule, new ArrayList<>(Collections.nCopies(rule.getLength(), 0)));
        });
  }
 public static ApostolicoGiancarlo getInstance(Rules rules) {
   if (instance == null) {
     instance = new ApostolicoGiancarlo();
   }
   instance.changeRules(rules);
   return instance;
 }