summaryrefslogtreecommitdiffstats
path: root/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-11-08 10:13:36 +0100
committerMaros Marsalek <mmarsale@cisco.com>2016-11-08 13:17:57 +0100
commit757222979bc02d0aaba1870eea36413383d15bde (patch)
tree3fe2a502026fbfa9a4ae5627e1a453a057f6c1fa /infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
parent03a638b95da83e150d4f69451c8733b5f09c37aa (diff)
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 <mmarsale@cisco.com>
Diffstat (limited to 'infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java')
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java9
1 files changed, 3 insertions, 6 deletions
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
index 40c78b3c9..b19b72ecf 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java
@@ -56,18 +56,15 @@ public abstract class AbstractGenericReader<D extends DataObject, B extends Buil
@Nonnull final ReadContext ctx) throws ReadFailedException {
LOG.debug("{}: Reading current: {}", this, id);
final B builder = getBuilder(id);
- // The empty value could be cached, but no caching is safer since we call overridden getBuilder each time
- // and the build could produce something different (even if it shouldn't)
- final D emptyValue = builder.build();
LOG.trace("{}: Reading current attributes", this);
readCurrentAttributes(id, builder, ctx);
// Need to check whether anything was filled in to determine if data is present or not.
final D built = builder.build();
- final Optional<D> read = built.equals(emptyValue)
- ? Optional.absent()
- : Optional.of(built);
+ final Optional<D> read = isPresent(id, built, ctx)
+ ? Optional.of(built)
+ : Optional.absent();
LOG.debug("{}: Current node read successfully. Result: {}", this, read);
return read;