code: public static String parseNamePartFromEmailAddressIfNecessary(final String username) {
          if (StringUtils.isBlank(username)) {
              return null;
          }
  
          final int idx = username.indexOf('@');
          if (idx == -1) {
              return username;
          }
          return username.substring(0, idx);
      }
docs: Parses the <code>username</code> and transforms it back if the value is recognized as en email address.
  Otherwise, returns the original value.
  
  @param username username or email address of the principal passed. A valid email address would be in the format of
  "user@domain.edu"
  @return Transformed <code>username</code> or <code>null</code> if <code>username</code> is <code>null</code> or blank.