/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.camel.builder;

import java.util.concurrent.TimeUnit;

import org.apache.camel.spi.ThreadPoolProfile;
import org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy;

/**
 * Builder to build {@link org.apache.camel.spi.ThreadPoolProfile}.
 * <p/>
 * Use the {@link #build()} method when done setting up the profile.
 */
public class ThreadPoolProfileBuilder {
    private final ThreadPoolProfile profile;

    public ThreadPoolProfileBuilder(String id) {
        this.profile = new ThreadPoolProfile(id);
    }

    public ThreadPoolProfileBuilder(String id, ThreadPoolProfile origProfile) {
        this.profile = origProfile.clone();
        this.profile.setId(id);
    }

    public ThreadPoolProfileBuilder defaultProfile(Boolean defaultProfile) {
        this.profile.setDefaultProfile(defaultProfile);
        return this;
    }

    public ThreadPoolProfileBuilder poolSize(Integer poolSize) {
        profile.setPoolSize(poolSize);
        return this;
    }

    public ThreadPoolProfileBuilder maxPoolSize(Integer maxPoolSize) {
        profile.setMaxPoolSize(maxPoolSize);
        return this;
    }

    public ThreadPoolProfileBuilder keepAliveTime(Long keepAliveTime, TimeUnit timeUnit) {
        profile.setKeepAliveTime(keepAliveTime);
        profile.setTimeUnit(timeUnit);
        return this;
    }

    public ThreadPoolProfileBuilder keepAliveTime(Long keepAliveTime) {
        profile.setKeepAliveTime(keepAliveTime);
        return this;
    }

    public ThreadPoolProfileBuilder maxQueueSize(Integer maxQueueSize) {
        if (maxQueueSize != null) {
            profile.setMaxQueueSize(maxQueueSize);
        }
        return this;
    }

    public ThreadPoolProfileBuilder allowCoreThreadTimeOut(Boolean allowCoreThreadTimeOut) {
        profile.setAllowCoreThreadTimeOut(allowCoreThreadTimeOut);
        return this;
    }

    public ThreadPoolProfileBuilder rejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) {
        profile.setRejectedPolicy(rejectedPolicy);
        return this;
    }

    /**
     * Builds the thread pool profile
     * 
     * @return the thread pool profile
     */
    public ThreadPoolProfile build() {
        return profile;
    }

}

@@ -1561,32 +1561,74 @@
 faultProfile) %7B%0A
+        if (defaultProfile != null) %7B%0A    
         this.pro
@@ -1663,24 +1663,34 @@
 ltProfile);%0A
+        %7D%0A
         retu
@@ -1762,32 +1762,68 @@
 ger poolSize) %7B%0A
+        if (poolSize != null) %7B%0A    
         profile.
@@ -1837,32 +1837,42 @@
 Size(poolSize);%0A
+        %7D%0A
         return t
@@ -1946,32 +1946,71 @@
  maxPoolSize) %7B%0A
+        if (maxPoolSize != null) %7B%0A    
         profile.
@@ -2030,32 +2030,42 @@
 e(maxPoolSize);%0A
+        %7D%0A
         return t
@@ -2163,24 +2163,65 @@
 timeUnit) %7B%0A
+        if (keepAliveTime != null) %7B%0A    
         prof
@@ -2249,32 +2249,78 @@
 keepAliveTime);%0A
+        %7D%0A        if (timeUnit != null) %7B%0A    
         profile.
@@ -2338,24 +2338,34 @@
 (timeUnit);%0A
+        %7D%0A
         retu
@@ -2448,24 +2448,65 @@
 liveTime) %7B%0A
+        if (keepAliveTime != null) %7B%0A    
         prof
@@ -2534,32 +2534,42 @@
 keepAliveTime);%0A
+        %7D%0A
         return t
@@ -2867,24 +2867,74 @@
 dTimeOut) %7B%0A
+        if (allowCoreThreadTimeOut != null) %7B%0A    
         prof
@@ -2984,24 +2984,34 @@
 adTimeOut);%0A
+        %7D%0A
         retu
@@ -3116,24 +3116,66 @@
 edPolicy) %7B%0A
+        if (rejectedPolicy != null) %7B%0A    
         prof
@@ -3213,16 +3213,26 @@
 olicy);%0A
+        %7D%0A
         

Fix thread pool profile builder to skip settign null values.