From 757222979bc02d0aaba1870eea36413383d15bde Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Tue, 8 Nov 2016 10:13:36 +0100 Subject: HONEYCOMB-270 Add isPresent() to Readers/Customizers So that they can influence whether empty data is to be considered as present + Move registries implementations from util to impl + Introduce DelegatingReader trait + Extend GenericReader where possible to reduce duplication Change-Id: I5a416acd0c4eab1fbc30fcbe585719991dbe9215 Signed-off-by: Maros Marsalek --- .../fd/honeycomb/translate/spi/read/ReaderCustomizer.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'infra/translate-spi/src') diff --git a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java index acfabf5bc..738431eea 100644 --- a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java +++ b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java @@ -57,4 +57,19 @@ public interface ReaderCustomizer> { void merge(@Nonnull final Builder parentBuilder, @Nonnull final O readValue); + /** + * Check whether the resulting value should be added to the results or ignored. + * Invoked after {@link #readCurrentAttributes(InstanceIdentifier, Builder, ReadContext)} + * + * @param id Keyed instance identifier of read data + * @param built Read data as returned from builder + * after {@link #readCurrentAttributes(InstanceIdentifier, Builder, ReadContext)} invocation + * @param ctx Read context + * + * @return true if value is present (even if empty) + */ + default boolean isPresent(final InstanceIdentifier id, final O built, final ReadContext ctx) throws ReadFailedException { + // Default impl = check whether read value is empty + return !built.equals(getBuilder(id).build()); + } } -- cgit 1.2.3-korg