Skip to content

Commit

Permalink
Add methods to get measurements by type (#1782)
Browse files Browse the repository at this point in the history
Signed-off-by: RALAMBOTIANA MIORA <[email protected]>
  • Loading branch information
miovd committed Jul 7, 2021
1 parent 95fadc4 commit 092d0f8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ default String getName() {

Collection<DiscreteMeasurement> getDiscreteMeasurements();

Collection<DiscreteMeasurement> getDiscreteMeasurements(DiscreteMeasurement.Type type);

DiscreteMeasurement getDiscreteMeasurement(String id);

DiscreteMeasurementAdder newDiscreteMeasurement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ default String getName() {

Collection<Measurement> getMeasurements();

Collection<Measurement> getMeasurements(Measurement.Type type);

Measurement getMeasurement(String id);

MeasurementAdder newMeasurement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author Miora Ralambotiana <miora.ralambotiana at rte-france.com>
Expand All @@ -38,6 +39,11 @@ public Collection<DiscreteMeasurement> getDiscreteMeasurements() {
return Collections.unmodifiableList(discreteMeasurements);
}

@Override
public Collection<DiscreteMeasurement> getDiscreteMeasurements(DiscreteMeasurement.Type type) {
return discreteMeasurements.stream().filter(dm -> dm.getType() == type).collect(Collectors.toList());
}

@Override
public DiscreteMeasurement getDiscreteMeasurement(String id) {
return discreteMeasurements.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author Miora Ralambotiana <miora.ralambotiana at rte-france.com>
Expand All @@ -38,6 +39,11 @@ public Collection<Measurement> getMeasurements() {
return Collections.unmodifiableList(measurements);
}

@Override
public Collection<Measurement> getMeasurements(Measurement.Type type) {
return measurements.stream().filter(m -> m.getType() == type).collect(Collectors.toList());
}

@Override
public Measurement getMeasurement(String id) {
return measurements.stream()
Expand Down

0 comments on commit 092d0f8

Please sign in to comment.