AnalyzerInfo.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package cz.senslog.analyzer.analysis;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import static java.util.Collections.unmodifiableList;
  5. public class AnalyzerInfo {
  6. enum Status {
  7. }
  8. static class HandlerInfo {
  9. private final String name;
  10. private final Status status;
  11. private final String configHash;
  12. public HandlerInfo(String name, Status status, String configHash) {
  13. this.name = name;
  14. this.status = status;
  15. this.configHash = configHash;
  16. }
  17. public String getName() {
  18. return name;
  19. }
  20. public Status getStatus() {
  21. return status;
  22. }
  23. public String getConfigHash() {
  24. return configHash;
  25. }
  26. }
  27. public static Builder create(Status status) {
  28. return new BuilderImpl(status);
  29. }
  30. interface Builder {
  31. Builder addHandlerInfo(HandlerInfo handlerInfo);
  32. AnalyzerInfo get();
  33. }
  34. private static class BuilderImpl implements Builder {
  35. private List<HandlerInfo> handlers;
  36. private Status status;
  37. private BuilderImpl(Status status) {
  38. this.status = status;
  39. this.handlers = new ArrayList<>();
  40. }
  41. @Override
  42. public Builder addHandlerInfo(HandlerInfo handlerInfo) {
  43. handlers.add(handlerInfo);
  44. return this;
  45. }
  46. @Override
  47. public AnalyzerInfo get() {
  48. return new AnalyzerInfo(unmodifiableList(handlers), status);
  49. }
  50. }
  51. private final List<HandlerInfo> handlerInfos;
  52. private final Status status;
  53. private AnalyzerInfo(List<HandlerInfo> handlerInfos, Status status) {
  54. this.handlerInfos = handlerInfos;
  55. this.status = status;
  56. }
  57. public List<HandlerInfo> getHandlerInfos() {
  58. return handlerInfos;
  59. }
  60. public Status getStatus() {
  61. return status;
  62. }
  63. }