CloudnamePath { public static boolean isValidPathElementName(final String name) { if (name == null || name.isEmpty()) { return false; } final Matcher matcher = NAME_PATTERN.matcher(name); if (!matcher.matches()) { return false; } if (name.length() > 64) { return false; } if (name.charAt(0) == '-' || name.charAt(name.length() - 1) == '-') { return false; } return true; } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); static boolean isValidPathElementName(final String name); int length(); String join(final char separator); String get(final int index); boolean isSubpathOf(final CloudnamePath other); CloudnamePath getParent(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString();  }
@Test public void invalidPathNameWithHyphenFirst() { assertThat(CloudnamePath.isValidPathElementName("-invalid"), is(false)); }
@Test public void invalidPathNameIsNull() { assertThat(CloudnamePath.isValidPathElementName(null), is(false)); }
@Test public void invalidPathNameWithHyphenLast() { assertThat(CloudnamePath.isValidPathElementName("invalid-"), is(false)); }
@Test public void invalidPathNameWithEmptyString() { assertThat(CloudnamePath.isValidPathElementName(""), is(false)); }
@Test public void invalidPathNameWithIllegalChars() { assertThat(CloudnamePath.isValidPathElementName("__"), is(false)); }
@Test public void invalidPathNameWithTooLongLabel() { assertThat(CloudnamePath.isValidPathElementName( "sojarindfleischetikettierungsueberwachungsaufgabenuebertragungsgesetz"), is(false)); }