// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java
// public class RequestMarshallerImpl implements RequestMarshaller {
// 
//     private final String contentType;
//     
//     private Marshaller marshaller;
//     
//     public RequestMarshallerImpl(String contentType) {
//         this.contentType = contentType;
//     }
//     
//     public void with(Marshaller marshaller) {
//         this.marshaller = marshaller;
//     }
//     
//     public String getContentType() {
//         return contentType;
//     }
//     
//     public Marshaller getMarshaller() {
//         return marshaller;
//     }
// }
// 
// Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java
// public class RequestUnmarshallerImpl implements RequestUnmarshaller {
// 
// private final String contentType;
//     
//     private Unmarshaller unmarshaller;
//     
//     public RequestUnmarshallerImpl(String contentType) {
//         this.contentType = contentType;
//     }
//     
//     public void with(Unmarshaller unmarshaller) {
//         this.unmarshaller = unmarshaller;
//     }
//     
//     public String getContentType() {
//         return contentType;
//     }
//     
//     public Unmarshaller getUnmarshaller() {
//         return unmarshaller;
//     }
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java
// public interface Marshaller {
// 
//     InputStream marshal(Object entity);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java
// public interface MarshallerProvider {
// 
//     /**
//      * 
//      * Returns the Marshaller for the given content-type,
//      * or null if there is no Marshaller for the given
//      * content-type.
//      * 
//      * @param contentType
//      * @return the Marshaller for the given content-type, or
//      *         null if there is no Marshaller for the given
//      *         content-type
//      */
//     Marshaller getMarshaller(String contentType);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java
// public interface Unmarshaller {
// 
//     <T> T unmarshal(InputStream in, Class<T> type);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java
// public interface UnmarshallerProvider {
// 
//     /**
//      * 
//      * Returns the Unmarshaller for the given content-type,
//      * or null if there is no Unmarshaller for the given
//      * content-type.
//      * 
//      * @param contentType
//      * @return the Unmarshaller for the given content-type, or
//      *         null if there is no Unmarshaller for the given
//      *         content-type
//      */
//     Unmarshaller getUnmarshaller(String contentType);
// }


import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bigtesting.fixd.core.RequestMarshallerImpl;
import org.bigtesting.fixd.core.RequestUnmarshallerImpl;
import org.bigtesting.fixd.marshalling.Marshaller;
import org.bigtesting.fixd.marshalling.MarshallerProvider;
import org.bigtesting.fixd.marshalling.Unmarshaller;
import org.bigtesting.fixd.marshalling.UnmarshallerProvider;
/*
 * Copyright (C) 2015 BigTesting.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.bigtesting.fixd.core.container;



/**
 * 
 * @author Luis Antunes
 */
class MarshallerContainer {
    
    private final Map<String, RequestMarshallerImpl> contentMarshallers = 
            new ConcurrentHashMap<String, RequestMarshallerImpl>();
    
    private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = 
            new ConcurrentHashMap<String, RequestUnmarshallerImpl>();
    
    public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) {
        
        this.contentMarshallers.put(contentType, marshaller);
    }
    
    public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) {
        
        this.contentUnmarshallers.put(contentType, unmarshaller);
    }

    public MarshallerProvider newMarshallerProvider() {
        return new MarshallerProvider() {
            public Marshaller getMarshaller(String contentType) {
                RequestMarshallerImpl marsh = contentMarshallers.get(contentType);
                return marsh != null ? marsh.getMarshaller() : null;
            }
        };
    }
    
    public UnmarshallerProvider newUnmarshallerProvider() {
        return new UnmarshallerProvider() {
// Path: src/main/java/org/bigtesting/fixd/core/RequestMarshallerImpl.java
// public class RequestMarshallerImpl implements RequestMarshaller {
// 
//     private final String contentType;
//     
//     private Marshaller marshaller;
//     
//     public RequestMarshallerImpl(String contentType) {
//         this.contentType = contentType;
//     }
//     
//     public void with(Marshaller marshaller) {
//         this.marshaller = marshaller;
//     }
//     
//     public String getContentType() {
//         return contentType;
//     }
//     
//     public Marshaller getMarshaller() {
//         return marshaller;
//     }
// }
// 
// Path: src/main/java/org/bigtesting/fixd/core/RequestUnmarshallerImpl.java
// public class RequestUnmarshallerImpl implements RequestUnmarshaller {
// 
// private final String contentType;
//     
//     private Unmarshaller unmarshaller;
//     
//     public RequestUnmarshallerImpl(String contentType) {
//         this.contentType = contentType;
//     }
//     
//     public void with(Unmarshaller unmarshaller) {
//         this.unmarshaller = unmarshaller;
//     }
//     
//     public String getContentType() {
//         return contentType;
//     }
//     
//     public Unmarshaller getUnmarshaller() {
//         return unmarshaller;
//     }
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/Marshaller.java
// public interface Marshaller {
// 
//     InputStream marshal(Object entity);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/MarshallerProvider.java
// public interface MarshallerProvider {
// 
//     /**
//      * 
//      * Returns the Marshaller for the given content-type,
//      * or null if there is no Marshaller for the given
//      * content-type.
//      * 
//      * @param contentType
//      * @return the Marshaller for the given content-type, or
//      *         null if there is no Marshaller for the given
//      *         content-type
//      */
//     Marshaller getMarshaller(String contentType);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/Unmarshaller.java
// public interface Unmarshaller {
// 
//     <T> T unmarshal(InputStream in, Class<T> type);
// }
// 
// Path: src/main/java/org/bigtesting/fixd/marshalling/UnmarshallerProvider.java
// public interface UnmarshallerProvider {
// 
//     /**
//      * 
//      * Returns the Unmarshaller for the given content-type,
//      * or null if there is no Unmarshaller for the given
//      * content-type.
//      * 
//      * @param contentType
//      * @return the Unmarshaller for the given content-type, or
//      *         null if there is no Unmarshaller for the given
//      *         content-type
//      */
//     Unmarshaller getUnmarshaller(String contentType);
// }


// Path: src/main/java/org/bigtesting/fixd/core/container/MarshallerContainer.java
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bigtesting.fixd.core.RequestMarshallerImpl;
import org.bigtesting.fixd.core.RequestUnmarshallerImpl;
import org.bigtesting.fixd.marshalling.Marshaller;
import org.bigtesting.fixd.marshalling.MarshallerProvider;
import org.bigtesting.fixd.marshalling.Unmarshaller;
import org.bigtesting.fixd.marshalling.UnmarshallerProvider;

/*
 * Copyright (C) 2015 BigTesting.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.bigtesting.fixd.core.container;



/**
 * 
 * @author Luis Antunes
 */
class MarshallerContainer {
    
    private final Map<String, RequestMarshallerImpl> contentMarshallers = 
            new ConcurrentHashMap<String, RequestMarshallerImpl>();
    
    private final Map<String, RequestUnmarshallerImpl> contentUnmarshallers = 
            new ConcurrentHashMap<String, RequestUnmarshallerImpl>();
    
    public void addContentMarshaller(String contentType, RequestMarshallerImpl marshaller) {
        
        this.contentMarshallers.put(contentType, marshaller);
    }
    
    public void addContentUnmarshaller(String contentType, RequestUnmarshallerImpl unmarshaller) {
        
        this.contentUnmarshallers.put(contentType, unmarshaller);
    }

    public MarshallerProvider newMarshallerProvider() {
        return new MarshallerProvider() {
            public Marshaller getMarshaller(String contentType) {
                RequestMarshallerImpl marsh = contentMarshallers.get(contentType);
                return marsh != null ? marsh.getMarshaller() : null;
            }
        };
    }
    
    public UnmarshallerProvider newUnmarshallerProvider() {
        return new UnmarshallerProvider() {
            public Unmarshaller getUnmarshaller(String contentType) {