コード例 #1
0
 /**
  * Get the class name without the qualified package name.
  *
  * @param className the className to get the short name for
  * @return the class name of the class without the package name
  * @throws IllegalArgumentException if the className is empty
  */
 public static String getShortName(String className) {
   Assert.hasLength(className, "Class name must not be empty");
   int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
   int nameEndIndex = className.indexOf(CGLIB_CLASS_SEPARATOR);
   if (nameEndIndex == -1) {
     nameEndIndex = className.length();
   }
   String shortName = className.substring(lastDotIndex + 1, nameEndIndex);
   shortName = shortName.replace(INNER_CLASS_SEPARATOR, PACKAGE_SEPARATOR);
   return shortName;
 }
コード例 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void hasLengthWithEmptyStringThrowsException() throws Exception {
   Assert.hasLength("");
 }
コード例 #3
0
 @Test
 public void hasLengthSunnyDay() throws Exception {
   Assert.hasLength("I Heart ...");
 }
コード例 #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testHasLengthWithNullStringThrowsException() throws Exception {
   Assert.hasLength(null);
 }
コード例 #5
0
 @Test
 public void hasLengthWithWhitespaceOnlyStringDoesNotThrowException() throws Exception {
   Assert.hasLength("\t  ");
 }