public Object getUserIdOrUsername(Object obj) throws GitLabApiException {

        if (obj == null) {
            throw (new RuntimeException("Cannot determine ID or username from null object"));
        } else if (obj instanceof Integer) {
            return (obj);
        } else if (obj instanceof String) {
            return (urlEncode(((String) obj).trim()));
        } else if (obj instanceof User) {

            Integer id = ((User) obj).getId();
            if (id != null && id.intValue() > 0) {
                return (id);
            }

            String username = ((User) obj).getUsername();
            if (username != null && username.trim().length() > 0) {
                return (urlEncode(username.trim()));
            }

            throw (new RuntimeException("Cannot determine ID or username from provided User instance"));

        } else {

            throw (new RuntimeException("Cannot determine ID or username from provided " + obj.getClass().getSimpleName() +
                    " instance, must be Integer, String, or a User instance"));
        }
    }
public Object getUserIdOrUsername ( Object obj ) throws GitLabApiException { if ( obj == null ) { throw ( new RuntimeException ( "Cannot determine ID or username from null object" ) ) ; } else if ( obj instanceof Integer ) { return ( obj ) ; } else if ( obj instanceof String ) { return ( urlEncode ( ( ( String ) obj ) . trim ( ) ) ) ; } else if ( obj instanceof User ) { Integer id = ( ( User ) obj ) . getId ( ) ; if ( id != null && id . intValue ( ) > 0 ) { return ( id ) ; } String username = ( ( User ) obj ) . getUsername ( ) ; if ( username != null && username . trim ( ) . length ( ) > 0 ) { return ( urlEncode ( username . trim ( ) ) ) ; } throw ( new RuntimeException ( "Cannot determine ID or username from provided User instance" ) ) ; } else { throw ( new RuntimeException ( "Cannot determine ID or username from provided " + obj . getClass ( ) . getSimpleName ( ) + " instance, must be Integer, String, or a User instance" ) ) ; } }
Returns the user ID or path from the provided Integer, String, or User instance.

@param obj the object to determine the ID or username from
@return the user ID or username from the provided Integer, String, or User instance
@throws GitLabApiException if any exception occurs during execution