config-manager: final parameters
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / TestingParallelAPSPImpl.java
1 /*
2  * Copyright (c) 2013 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.controller.config.manager.testingservices.parallelapsp;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11
12 import com.google.common.base.Strings;
13 import java.io.Closeable;
14 import java.io.IOException;
15 import javax.annotation.concurrent.NotThreadSafe;
16 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
17
18 @NotThreadSafe
19 public class TestingParallelAPSPImpl implements TestingAPSP, Closeable {
20     public static final int MINIMAL_NUMBER_OF_THREADS = 10;
21     private TestingThreadPoolIfc threadPool;
22     private String someParam;
23
24     public TestingParallelAPSPImpl(final TestingThreadPoolIfc threadPool,
25             final String someParam) {
26         checkArgument(
27                 threadPool.getMaxNumberOfThreads() >= MINIMAL_NUMBER_OF_THREADS,
28                 "Parameter 'threadPool' has not enough threads");
29         checkArgument(Strings.isNullOrEmpty(someParam) == false,
30                 "Parameter 'someParam' is blank");
31         this.threadPool = threadPool;
32         this.someParam = someParam;
33     }
34
35     @Override
36     public int getMaxNumberOfThreads() {
37         return threadPool.getMaxNumberOfThreads();
38     }
39
40     @Override
41     public void close() throws IOException {
42
43     }
44
45     TestingThreadPoolIfc getThreadPool() {
46         return threadPool;
47     }
48
49     void setSomeParam(final String s) {
50         checkArgument(Strings.isNullOrEmpty(someParam) == false,
51                 "Parameter 'someParam' is blank");
52         this.someParam = s;
53     }
54
55     public String getSomeParam() {
56         return someParam;
57     }
58
59 }