PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/testability-explorer/src/test/java/com/google/test/metric/testing/MetricComputerBuilder.java

http://testability-explorer.googlecode.com/
Java | 58 lines | 26 code | 10 blank | 22 comment | 0 complexity | 57c319771c7e280a6f4e7cdecbb69dff MD5 | raw file
 1/*
 2 * Copyright 2008 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
17package com.google.test.metric.testing;
18
19import java.io.PrintStream;
20
21import com.google.test.metric.ClassRepository;
22import com.google.test.metric.JavaClassRepository;
23import com.google.test.metric.MetricComputer;
24import com.google.test.metric.RegExpWhiteList;
25
26/**
27 * For use in tests, this is a preferable way to construct a {@code MetricComputer},
28 * as opposed to inheriting from a TestCase that does it for you. Prefer composition
29 * over inheritance.
30 *
31 * @author Jonathan Andrew Wolter
32 */
33public class MetricComputerBuilder {
34
35  private ClassRepository repo = new JavaClassRepository();
36  private PrintStream printStream = null;
37  private RegExpWhiteList whitelist = new RegExpWhiteList();
38
39  public MetricComputerBuilder withClassRepository(ClassRepository repository) {
40    this.repo = repository;
41    return this;
42  }
43
44  public MetricComputerBuilder withPrintStream(PrintStream stream) {
45    this.printStream = stream;
46    return this;
47  }
48
49  public MetricComputerBuilder withWhitelist(RegExpWhiteList regExpWhitelist) {
50    this.whitelist = regExpWhitelist;
51    return this;
52  }
53
54  public MetricComputer build() {
55    return new MetricComputer(repo, printStream, whitelist, 1);
56  }
57
58}