下面列出了org.apache.http.util.Asserts#notNull ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public Refund createRefund(Refund refund) throws HTTPException, ConnectionException {
Asserts.notNull(refund, "Refund");
try {
String response = HttpUtils.post(context.getApiPath(Constants.PATH_REFUND + refund.getPaymentId() + "" +
"/refund/"), getHeaders(), gson.toJson(refund));
Type type = new TypeToken<ApiResponse<Refund>>() {
}.getType();
ApiResponse<Refund> createRefundResponse = gson.fromJson(response, type);
return createRefundResponse.getResult();
} catch (IOException e) {
throw new ConnectionException(e.getMessage(), e);
}
}
@Override
public IndexResult index(List<Document> docs) {
Asserts.notNull(docs,"Document to index should not be null.");
Asserts.check(!docs.isEmpty(), "Should be at least one document to index.");
return indexMultipleDocuments(docs, -1);
}
@Override
public IndexResult indexWithin(List<Document> docs, int withinMs) {
Asserts.notNull(docs,"Document to index should not be null.");
Asserts.check(!docs.isEmpty(), "Should be at least one document to index.");
log.warn("Parameter 'within' not in use in elastic search backend");
return indexMultipleDocuments(docs, withinMs);
}
@Override
public IndexResult index(List<Document> docs) {
Asserts.notNull(docs,"Document to index should not be null.");
Asserts.check(docs.size() > 0, "Should be at least one document to index.");
return indexMultipleDocuments(docs, -1);
}
@Override
public PaymentOrderResponse createPaymentOrder(PaymentOrder paymentOrder) throws HTTPException, ConnectionException {
Asserts.notNull(paymentOrder, "Payment Order");
try {
String response = HttpUtils.post(context.getApiPath(Constants.PATH_PAYMENT_ORDER), getHeaders(),
gson.toJson(paymentOrder));
return gson.fromJson(response, PaymentOrderResponse.class);
} catch (IOException e) {
throw new ConnectionException(e.getMessage(), e);
}
}
@Override
public PaymentRequest createPaymentRequest(PaymentRequest paymentRequest) throws ConnectionException, HTTPException {
Asserts.notNull(paymentRequest, "payment request");
try {
String response = HttpUtils.post(
context.getApiPath(Constants.PATH_PAYMENT_REQUEST), getHeaders(), gson.toJson(paymentRequest));
return gson.fromJson(response, PaymentRequest.class);
} catch (IOException e) {
throw new ConnectionException(e.getMessage(), e);
}
}
public HttpEntity builder() {
Asserts.notNull(this.entityBuilder, "entityBuilder should not be null");
return this.entityBuilder.build();
}
public HttpEntity builder() {
Asserts.notNull(multipartEntityBuilder, "entityBuilder should not be null");
return this.multipartEntityBuilder.build();
}
@Override
public IndexResult index(Document... docs) {
Asserts.notNull(docs,"Document to index should not be null.");
Asserts.check(docs.length > 0, "Should be at least one document to index.");
return indexMultipleDocuments(Arrays.asList(docs), -1);
}
@Override
public IndexResult indexWithin(Document doc, int withinMs) {
Asserts.notNull(doc,"Document to index should not be null.");
log.warn("Parameter 'within' not in use in elastic search backend");
return indexMultipleDocuments(Collections.singletonList(doc), withinMs);
}
@Override
public IndexResult index(Document ... docs) {
Asserts.notNull(docs,"Document to index should not be null.");
Asserts.check(docs.length > 0, "Should be at least one document to index.");
return indexMultipleDocuments(Arrays.asList(docs), -1);
}
public static JkesProperties getJkesProperties() {
Asserts.notNull(jkesProperties, "JkesProperties config must be set into Config");
return jkesProperties;
}