Remove use of commons-lang3 in restconf-nb-rfc8040
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / rests / utils / ResponseFactory.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.nb.rfc8040.rests.utils;
9
10 import java.net.URI;
11 import javax.ws.rs.core.Response;
12 import javax.ws.rs.core.Response.ResponseBuilder;
13 import javax.ws.rs.core.Response.Status;
14 import org.opendaylight.yangtools.concepts.Builder;
15
16 final class ResponseFactory extends FutureDataFactory<Void> implements Builder<Response> {
17
18     private ResponseBuilder responseBuilder;
19
20     ResponseFactory(final Status status) {
21         this.responseBuilder = Response.status(status);
22     }
23
24     ResponseFactory location(final URI location) {
25         responseBuilder.location(location);
26         return this;
27     }
28
29     @Override
30     public Response build() {
31         if (getFailureStatus()) {
32             responseBuilder = responseBuilder.status(Response.Status.INTERNAL_SERVER_ERROR);
33         }
34         return this.responseBuilder.build();
35     }
36 }