@Override public int hashCode() { HashCodeBuilder builder = new HashCodeBuilder(); builder.append( _request.getBaseUriTemplate() ) .append( _request.getPathKeys() ) .append( _request.getResourceProperties() ) .append( _request.getRequestOptions() ) .append( _queryParams ); if(_batchFields && null != _request.getFields()) builder.append( _request.getFields() ); return builder.toHashCode(); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof BatchingKey)) return false; @SuppressWarnings("unchecked") BatchingKey<T,R> that = (BatchingKey<T,R>) o; EqualsBuilder builder = new EqualsBuilder(); builder.append(_request.getBaseUriTemplate(), that._request.getBaseUriTemplate()); builder.append(_request.getPathKeys(), that._request.getPathKeys()); builder.append(_request.getResourceProperties(), that._request.getResourceProperties()); builder.append(_request.getRequestOptions(), that._request.getRequestOptions()); builder.append(_queryParams, that._queryParams); builder.append(_batchFields, that._batchFields ); if (_batchFields) builder.append(_request.getFields(), that._request.getFields()); return builder.isEquals(); }
/** * This method provides granular exception messages for developers to know why a request * intended to be added to a batch, might fail to be batched. * * @param request the request to validate is the same or not * @throws IllegalArgumentException if there are any problems */ public <T> void validate(BatchRequest<T> request) { if( !request.getBaseUriTemplate().equals(_request.getBaseUriTemplate()) || !request.getPathKeys().equals(_request.getPathKeys()) ) { throw new IllegalArgumentException("Requests must have same base URI template and path keys to batch"); } if( !request.getResourceProperties().equals(_request.getResourceProperties()) ) { throw new IllegalArgumentException("Requests must be for the same resource to batch"); } if( !request.getRequestOptions().equals(_request.getRequestOptions()) ) { throw new IllegalArgumentException("Requests must have the same RestliRequestOptions to batch!"); } // Enforce uniformity of query params excluding ids and fields final Map<String, Object> queryParams = BatchGetRequestUtil.getQueryParamsForBatchingKey(request); if ( !queryParams.equals(_queryParams) ) { throw new IllegalArgumentException("Requests must have same parameters to batch"); } if (!_batchFields) { if( !request.getFields().equals(_request.getFields()) ) { throw new IllegalArgumentException("Requests must have same fields to batch"); } } }