PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/testability-explorer/src/main/java/com/google/test/metric/AnalysisModel.java

http://testability-explorer.googlecode.com/
Java | 56 lines | 24 code | 7 blank | 25 comment | 2 complexity | 1c51958b34d556c2997c01e7cc156612 MD5 | raw file
 1/*
 2 * Copyright 2009 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 */
16package com.google.test.metric;
17
18import java.util.ArrayList;
19import java.util.List;
20
21import com.google.test.metric.report.issues.ClassIssues;
22import com.google.test.metric.report.issues.IssuesReporter;
23
24/**
25 * @author shyamseshadri@google.com (Shyam Seshadri)
26 */
27public class AnalysisModel {
28  private List<ClassCost> classCosts = new ArrayList<ClassCost>();
29  private final IssuesReporter issuesReporter;
30  
31  /**
32   * @param issuesReporter Can be {@code null}. 
33   */
34  public AnalysisModel(IssuesReporter issuesReporter) {
35    this.issuesReporter = issuesReporter;
36  }
37
38  public void addClassCost(ClassCost classCost) {
39    classCosts.add(classCost);
40    if (issuesReporter != null) {
41      issuesReporter.inspectClass(classCost);
42    }
43  }
44
45  public Iterable<ClassCost> getClassCosts() {
46    return classCosts;
47  }
48  
49  /**
50   * Can only be called if a non {@code null} {@link IssuesReporter} was passed
51   * to the constructor
52   */
53  public List<ClassIssues> getWorstOffenders() {
54    return issuesReporter.getMostImportantIssues();
55  }
56}