static public FileSize valueOf(String fileSizeStr) {
    Matcher matcher = FILE_SIZE_PATTERN.matcher(fileSizeStr);

    long coefficient;
    if (matcher.matches()) {
      String lenStr = matcher.group(DOUBLE_GROUP);
      String unitStr = matcher.group(UNIT_GROUP);

      long lenValue = Long.valueOf(lenStr);
      if (unitStr.equalsIgnoreCase("")) {
        coefficient = 1;
      } else if (unitStr.equalsIgnoreCase("kb")) {
        coefficient = KB_COEFFICIENT;
      } else if (unitStr.equalsIgnoreCase("mb")) {
        coefficient = MB_COEFFICIENT;
      } else if (unitStr.equalsIgnoreCase("gb")) {
        coefficient = GB_COEFFICIENT;
      } else {
        throw new IllegalStateException("Unexpected " + unitStr);
      }
      return new FileSize(lenValue * coefficient);
    } else {
      throw new IllegalArgumentException("String value [" + fileSizeStr
          + "] is not in the expected format.");
    }

  }
@Test
  public void testValueOf() {
    {
      FileSize fs = FileSize.valueOf("8");
      assertEquals(8, fs.getSize());
    }
    
    {
      FileSize fs = FileSize.valueOf("8 kbs");
      assertEquals(8*KB_CO, fs.getSize());
    }
  
    {
      FileSize fs = FileSize.valueOf("8 kb");
      assertEquals(8*KB_CO, fs.getSize());
    }
    
    {
      FileSize fs = FileSize.valueOf("12 mb");
      assertEquals(12*MB_CO, fs.getSize());
    }

    {
      FileSize fs = FileSize.valueOf("5 GBs");
      assertEquals(5*GB_CO, fs.getSize());
    }

  }