Skip to content

Package: ReportServiceImpl

ReportServiceImpl

nameinstructionbranchcomplexitylinemethod
ReportServiceImpl()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addConsumer(ReportServiceConsumer)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
clearReports()
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getReports()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
removeConsumer(ReportServiceConsumer)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
report(AbstractReport)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Edgar Mueller - initial API and implementation
13: * Eugen Neufeld - deprecated getReports and clearReports
14: ******************************************************************************/
15: package org.eclipse.emfforms.internal.common.report;
16:
17: import java.util.Collections;
18: import java.util.LinkedHashSet;
19: import java.util.List;
20: import java.util.Set;
21:
22: import org.eclipse.emfforms.spi.common.report.AbstractReport;
23: import org.eclipse.emfforms.spi.common.report.ReportService;
24: import org.eclipse.emfforms.spi.common.report.ReportServiceConsumer;
25: import org.osgi.service.component.annotations.Component;
26: import org.osgi.service.component.annotations.Reference;
27: import org.osgi.service.component.annotations.ReferenceCardinality;
28: import org.osgi.service.component.annotations.ReferencePolicy;
29:
30: /**
31: * Implementation of a {@link ReportService}.
32: *
33: * @author emueller
34: */
35: @Component
36: public class ReportServiceImpl implements ReportService {
37:
38:         private final Set<ReportServiceConsumer> consumers;
39:
40:         /**
41:          * Constructor.
42:          */
43:         public ReportServiceImpl() {
44:                 consumers = new LinkedHashSet<ReportServiceConsumer>();
45:         }
46:
47:         /**
48:          * Report an {@link AbstractReport} to the service.
49:          *
50:          * @param reportEntity
51:          * the report entity
52:          */
53:         @Override
54:         public void report(AbstractReport reportEntity) {
55:•                for (final ReportServiceConsumer consumer : consumers) {
56:                         consumer.reported(reportEntity);
57:                 }
58:         }
59:
60:         @Override
61:         @Deprecated
62:         public List<AbstractReport> getReports() {
63:                 return Collections.emptyList();
64:         }
65:
66:         @Override
67:         @Deprecated
68:         public void clearReports() {
69:                 // do nothing
70:         }
71:
72:         /**
73:          *
74:          * {@inheritDoc}
75:          *
76:          * @see org.eclipse.emfforms.spi.common.report.ReportService#addConsumer(org.eclipse.emfforms.spi.common.report.ReportServiceConsumer)
77:          */
78:         @Override
79:         @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
80:         public void addConsumer(ReportServiceConsumer consumer) {
81:                 consumers.add(consumer);
82:         }
83:
84:         /**
85:          *
86:          * {@inheritDoc}
87:          *
88:          * @see org.eclipse.emfforms.spi.common.report.ReportService#removeConsumer(org.eclipse.emfforms.spi.common.report.ReportServiceConsumer)
89:          */
90:         @Override
91:         public void removeConsumer(ReportServiceConsumer consumer) {
92:                 consumers.remove(consumer);
93:         }
94: }