docs: public void readExternal(ObjectInput stream) throws IOException,
              ClassNotFoundException {
          boolean isDroolsStream = stream instanceof DroolsObjectInputStream;
          DroolsObjectInputStream in = isDroolsStream ? (DroolsObjectInputStream) stream
                  : new DroolsObjectInputStream(
                  new ByteArrayInputStream(
                          (byte[]) stream.readObject()));
  
          this.name = (String) in.readObject();
          this.classFieldAccessorStore = (ClassFieldAccessorStore) in.readObject();
          in.setStore(this.classFieldAccessorStore);
  
          this.dialectRuntimeRegistry = (DialectRuntimeRegistry) in.readObject();
          this.typeDeclarations = (Map) in.readObject();
          this.imports = (Map<String, ImportDeclaration>) in.readObject();
          this.staticImports = (Set) in.readObject();
          this.functions = (Map<String, Function>) in.readObject();
          this.accumulateFunctions = (Map<String, AccumulateFunction>) in.readObject();
          this.factTemplates = (Map) in.readObject();
          this.globals = (Map<String, String>) in.readObject();
          this.valid = in.readBoolean();
          this.needStreamMode = in.readBoolean();
          this.rules = (Map<String, RuleImpl>) in.readObject();
          this.entryPointsIds = (Set<String>) in.readObject();
          this.windowDeclarations = (Map<String, WindowDeclaration>) in.readObject();
          this.traitRegistry = (TraitRegistry) in.readObject();
          this.resourceTypePackages = (ResourceTypePackageRegistry) in.readObject();
  
          in.setStore(null);
  
          if (!isDroolsStream) {
              in.close();
          }
      }