public List from()

in src/main/java/com/epam/digital/data/platform/restapi/core/converter/jooq/FileListConverter.java [38:74]


  public List from(Object o) {
    if (o == null) {
      return null;
    }
    if (o instanceof PgArray) {
      Object obj;
      try {
        obj = ((PgArray) o).getArray();
      } catch (SQLException e) {
        log.error("Cannot cast Object to PgArray", e);
        throw new RequestProcessingException("Exception", Status.OPERATION_FAILED);
      }
      
      Object[] array;
      if(obj instanceof Object[]) {
        array = (Object[]) obj; 
      } else {
        return null;
      }
      
      var files = new ArrayList<File>();
      for (Object tempObject : array) {
        if(tempObject instanceof PGobject) {
          var pgObject = (PGobject) tempObject;
          var file = new File();
          var valueStr = pgObject.getValue();
          String[] arr = valueStr.substring(1, valueStr.length() - 1).split(",");
          file.setId(arr[0]);
          file.setChecksum(arr[1]);
          files.add(file);
        }
      }
      return files;
    } else {
      return null;
    }
  }