code: @Override
      public <T extends IChemObject> T read(T object) throws CDKException {
          if (object instanceof RGroupQuery) {
              return (T) parseRGFile((RGroupQuery) object);
          } else {
              throw new CDKException("Reader only supports " + RGroupQuery.class.getName() + " objects");
          }
      }
docs: Check input IChemObject and proceed to parse.
  Accepts/returns IChemObject of type RGroupQuery only.
  @return IChemObject read from file
  @param object class must be of type RGroupQuery