@Test(expected = IllegalArgumentException.class) public void of_empty() { JavaName.of(""); }
public static JavaName of(String nameString) { Objects.requireNonNull(nameString, "nameString must not be null"); if (nameString.isEmpty()) { throw new IllegalArgumentException("nameString must not be empty"); } else if (nameString.indexOf('_') >= 0 || nameString.toUpperCase(Locale.ENGLISH).equals(nameString)) { String[] segments = nameString.split(EMPTY_NAME); return new JavaName(Arrays.asList(segments)); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = nameString.length(); i < n; i++) { if (Character.isUpperCase(nameString.charAt(i))) { segments.add(nameString.substring(start, i)); start = i; } } segments.add(nameString.substring(start)); return new JavaName(segments); } }
JavaName { public static JavaName of(String nameString) { Objects.requireNonNull(nameString, "nameString must not be null"); if (nameString.isEmpty()) { throw new IllegalArgumentException("nameString must not be empty"); } else if (nameString.indexOf('_') >= 0 || nameString.toUpperCase(Locale.ENGLISH).equals(nameString)) { String[] segments = nameString.split(EMPTY_NAME); return new JavaName(Arrays.asList(segments)); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = nameString.length(); i < n; i++) { if (Character.isUpperCase(nameString.charAt(i))) { segments.add(nameString.substring(start, i)); start = i; } } segments.add(nameString.substring(start)); return new JavaName(segments); } } }
JavaName { public static JavaName of(String nameString) { Objects.requireNonNull(nameString, "nameString must not be null"); if (nameString.isEmpty()) { throw new IllegalArgumentException("nameString must not be empty"); } else if (nameString.indexOf('_') >= 0 || nameString.toUpperCase(Locale.ENGLISH).equals(nameString)) { String[] segments = nameString.split(EMPTY_NAME); return new JavaName(Arrays.asList(segments)); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = nameString.length(); i < n; i++) { if (Character.isUpperCase(nameString.charAt(i))) { segments.add(nameString.substring(start, i)); start = i; } } segments.add(nameString.substring(start)); return new JavaName(segments); } } JavaName(List<String> words); }
JavaName { public static JavaName of(String nameString) { Objects.requireNonNull(nameString, "nameString must not be null"); if (nameString.isEmpty()) { throw new IllegalArgumentException("nameString must not be empty"); } else if (nameString.indexOf('_') >= 0 || nameString.toUpperCase(Locale.ENGLISH).equals(nameString)) { String[] segments = nameString.split(EMPTY_NAME); return new JavaName(Arrays.asList(segments)); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = nameString.length(); i < n; i++) { if (Character.isUpperCase(nameString.charAt(i))) { segments.add(nameString.substring(start, i)); start = i; } } segments.add(nameString.substring(start)); return new JavaName(segments); } } JavaName(List<String> words); static JavaName of(String nameString); List<String> getSegments(); String toTypeName(); String toMemberName(); String toConstantName(); String toSnakeName(); void addFirst(String segment); void removeFirst(); void addLast(String segment); void removeLast(); }
JavaName { public static JavaName of(String nameString) { Objects.requireNonNull(nameString, "nameString must not be null"); if (nameString.isEmpty()) { throw new IllegalArgumentException("nameString must not be empty"); } else if (nameString.indexOf('_') >= 0 || nameString.toUpperCase(Locale.ENGLISH).equals(nameString)) { String[] segments = nameString.split(EMPTY_NAME); return new JavaName(Arrays.asList(segments)); } else { List<String> segments = new ArrayList<>(); int start = 0; for (int i = 1, n = nameString.length(); i < n; i++) { if (Character.isUpperCase(nameString.charAt(i))) { segments.add(nameString.substring(start, i)); start = i; } } segments.add(nameString.substring(start)); return new JavaName(segments); } } JavaName(List<String> words); static JavaName of(String nameString); List<String> getSegments(); String toTypeName(); String toMemberName(); String toConstantName(); String toSnakeName(); void addFirst(String segment); void removeFirst(); void addLast(String segment); void removeLast();  }