Coverage Report - org.apache.johnzon.jaxrs.DelegateProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegateProvider
90 %
9/10
N/A
1
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements. See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership. The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License. You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied. See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.johnzon.jaxrs;
 20  
 
 21  
 import javax.ws.rs.core.MediaType;
 22  
 import javax.ws.rs.core.MultivaluedMap;
 23  
 import javax.ws.rs.ext.MessageBodyReader;
 24  
 import javax.ws.rs.ext.MessageBodyWriter;
 25  
 import java.io.IOException;
 26  
 import java.io.InputStream;
 27  
 import java.io.OutputStream;
 28  
 import java.lang.annotation.Annotation;
 29  
 import java.lang.reflect.Type;
 30  
 
 31  
 public abstract class DelegateProvider<T> implements MessageBodyWriter<T>, MessageBodyReader<T>  {
 32  
     private final MessageBodyReader<T> reader;
 33  
     private final MessageBodyWriter<T> writer;
 34  
 
 35  13
     protected DelegateProvider(final MessageBodyReader<T> reader, final MessageBodyWriter<T> writer) {
 36  13
         this.reader = reader;
 37  13
         this.writer = writer;
 38  13
     }
 39  
 
 40  
     @Override
 41  
     public boolean isReadable(final Class<?> rawType, final Type genericType,
 42  
                               final Annotation[] annotations, final MediaType mediaType) {
 43  12
         return reader.isReadable(rawType, genericType, annotations, mediaType);
 44  
     }
 45  
 
 46  
     @Override
 47  
     public T readFrom(final Class<T> rawType, final Type genericType,
 48  
                       final Annotation[] annotations, final MediaType mediaType,
 49  
                       final MultivaluedMap<String, String> httpHeaders,
 50  
                       final InputStream entityStream) throws IOException {
 51  10
         return reader.readFrom(rawType, genericType, annotations, mediaType, httpHeaders, entityStream);
 52  
     }
 53  
 
 54  
     @Override
 55  
     public long getSize(final T t, final Class<?> rawType, final Type genericType,
 56  
                         final Annotation[] annotations, final MediaType mediaType) {
 57  0
         return writer.getSize(t, rawType, genericType, annotations, mediaType);
 58  
     }
 59  
 
 60  
     @Override
 61  
     public boolean isWriteable(final Class<?> rawType, final Type genericType,
 62  
                                final Annotation[] annotations, final MediaType mediaType) {
 63  12
         return writer.isWriteable(rawType, genericType, annotations, mediaType);
 64  
     }
 65  
 
 66  
     @Override
 67  
     public void writeTo(final T t, final Class<?> rawType, final Type genericType,
 68  
                         final Annotation[] annotations, final MediaType mediaType,
 69  
                         final MultivaluedMap<String, Object> httpHeaders,
 70  
                         final OutputStream entityStream) throws IOException {
 71  10
         writer.writeTo(t, rawType, genericType, annotations, mediaType, httpHeaders, entityStream);
 72  10
     }
 73  
 }