NameChecker { public String checkStyleName(final String name) { if (name == null || name.isEmpty()) { throw new IllegalArgumentException(String.format("Bad name: %s", name)); } final int firstCodePoint = name.codePointAt(0); if (!this.isNCNameStartChar(firstCodePoint)) { throw new IllegalArgumentException( String.format("Bad first char %c (#x%x) in %s", firstCodePoint, firstCodePoint, name)); } for (int i = 1; i < name.length(); i++) { final int codePoint = name.codePointAt(i); if (!this.isNCNameChar(codePoint)) { throw new IllegalArgumentException( String.format("Bad char %d: %c (#x%x) in %s", i, codePoint, codePoint, name)); } } return name; }  String checkStyleName(final String name); boolean isNameStartChar(final int codePoint); boolean isNameChar(final int codePoint); boolean isNCNameStartChar(final int codePoint); boolean isNCNameChar(final int codePoint);  }
@Test(expected = IllegalArgumentException.class) public void wrongChildCellTest() { this.checker.checkStyleName("style@@datastyle"); }
@Test(expected = IllegalArgumentException.class) public void wrongChildCellTest2() { this.checker.checkStyleName("style-:-datastyle"); }
@Test public void correctChildCellTest() { this.checker.checkStyleName("style-_-datastyle"); }
@Test(expected = IllegalArgumentException.class) public void digitTest() { this.checker.checkStyleName("0style-:-datastyle"); }