private Integer getPriority(Map<String, Object> mutableRData) {
    Integer priority = null;

    if (mutableRData.containsKey("priority")) { // SRVData
      priority = Integer.class.cast(mutableRData.remove("priority"));
    } else if (mutableRData.containsKey("preference")) { // MXData
      priority = Integer.class.cast(mutableRData.remove("preference"));
    }

    return priority;
  }
private Integer getPriority ( Map < String , Object > mutableRData ) { Integer priority = null ; if ( mutableRData . containsKey ( "priority" ) ) { priority = Integer . class . cast ( mutableRData . remove ( "priority" ) ) ; } else if ( mutableRData . containsKey ( "preference" ) ) { priority = Integer . class . cast ( mutableRData . remove ( "preference" ) ) ; } return priority ; }
Has the side effect of removing the priority from the mutableRData.

@return null or the priority, if it exists for a MX or SRV record