@Test public void fromString_useX() { assertThat(Dimensions.fromString("50X60")).isEqualTo(new Dimensions(50, 60)); }
public static Dimensions fromString(final String string) { if (string.matches(PATTERN_SIMPLE.pattern())) { return new Dimensions(Integer.parseInt(string)); } else if (string.matches(PATTERN_X.pattern())) { final Matcher matcher = PATTERN_X.matcher(string); matcher.find(); return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } throw new IllegalArgumentException(string); }
Dimensions { public static Dimensions fromString(final String string) { if (string.matches(PATTERN_SIMPLE.pattern())) { return new Dimensions(Integer.parseInt(string)); } else if (string.matches(PATTERN_X.pattern())) { final Matcher matcher = PATTERN_X.matcher(string); matcher.find(); return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } throw new IllegalArgumentException(string); } }
Dimensions { public static Dimensions fromString(final String string) { if (string.matches(PATTERN_SIMPLE.pattern())) { return new Dimensions(Integer.parseInt(string)); } else if (string.matches(PATTERN_X.pattern())) { final Matcher matcher = PATTERN_X.matcher(string); matcher.find(); return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } throw new IllegalArgumentException(string); } Dimensions(final int height, final int width);  Dimensions(final int squareSize); }
Dimensions { public static Dimensions fromString(final String string) { if (string.matches(PATTERN_SIMPLE.pattern())) { return new Dimensions(Integer.parseInt(string)); } else if (string.matches(PATTERN_X.pattern())) { final Matcher matcher = PATTERN_X.matcher(string); matcher.find(); return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } throw new IllegalArgumentException(string); } Dimensions(final int height, final int width);  Dimensions(final int squareSize); int getHeight(); int getWidth(); Dimensions multiply(final int factor); Dimensions divide(final int divisor); Dimensions scaleToWidth(final int newWidth); Dimensions scaleToHeight(final int newHeight); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); static Dimensions fromString(final String string); }
Dimensions { public static Dimensions fromString(final String string) { if (string.matches(PATTERN_SIMPLE.pattern())) { return new Dimensions(Integer.parseInt(string)); } else if (string.matches(PATTERN_X.pattern())) { final Matcher matcher = PATTERN_X.matcher(string); matcher.find(); return new Dimensions(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2))); } throw new IllegalArgumentException(string); } Dimensions(final int height, final int width);  Dimensions(final int squareSize); int getHeight(); int getWidth(); Dimensions multiply(final int factor); Dimensions divide(final int divisor); Dimensions scaleToWidth(final int newWidth); Dimensions scaleToHeight(final int newHeight); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); static Dimensions fromString(final String string);  }