Search in sources :

Example 1 with SuccessStatusesSchema

use of com.linkedin.restli.restspec.SuccessStatusesSchema in project rest.li by linkedin.

the class ResourceModelEncoder method appendSuccessStatuses.

/**
 * Given a resource method schema, adds the specified success status codes.
 *
 * @param schema specific resource method schema
 * @param successStatuses list of success status codes to add to this schema
 */
private void appendSuccessStatuses(final RecordTemplate schema, final List<HttpStatus> successStatuses) {
    if (successStatuses == null || successStatuses.isEmpty()) {
        return;
    }
    // Wrap the underlying data map in the shared schema interface
    SuccessStatusesSchema successStatusesSchema = new SuccessStatusesSchema(schema.data());
    IntegerArray statuses = successStatuses.stream().map(HttpStatus::getCode).collect(Collectors.toCollection(IntegerArray::new));
    successStatusesSchema.setSuccess(statuses);
}
Also used : SuccessStatusesSchema(com.linkedin.restli.restspec.SuccessStatusesSchema) IntegerArray(com.linkedin.data.template.IntegerArray)

Aggregations

IntegerArray (com.linkedin.data.template.IntegerArray)1 SuccessStatusesSchema (com.linkedin.restli.restspec.SuccessStatusesSchema)1