PageRenderTime 28ms CodeModel.GetById 11ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  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. */
  16. package com.google.test.metric;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import com.google.test.metric.report.issues.ClassIssues;
  20. import com.google.test.metric.report.issues.IssuesReporter;
  21. /**
  22. * @author shyamseshadri@google.com (Shyam Seshadri)
  23. */
  24. public class AnalysisModel {
  25. private List<ClassCost> classCosts = new ArrayList<ClassCost>();
  26. private final IssuesReporter issuesReporter;
  27. /**
  28. * @param issuesReporter Can be {@code null}.
  29. */
  30. public AnalysisModel(IssuesReporter issuesReporter) {
  31. this.issuesReporter = issuesReporter;
  32. }
  33. public void addClassCost(ClassCost classCost) {
  34. classCosts.add(classCost);
  35. if (issuesReporter != null) {
  36. issuesReporter.inspectClass(classCost);
  37. }
  38. }
  39. public Iterable<ClassCost> getClassCosts() {
  40. return classCosts;
  41. }
  42. /**
  43. * Can only be called if a non {@code null} {@link IssuesReporter} was passed
  44. * to the constructor
  45. */
  46. public List<ClassIssues> getWorstOffenders() {
  47. return issuesReporter.getMostImportantIssues();
  48. }
  49. }