@Test public void testGetFieldsAvailableInRecord() { AuditRecord recordWithoutOptionals = SimpleAuditRecord.builder().build(); FieldSelector fields = FieldFilterFlavorAdapter.getFieldsAvailableInRecord(recordWithoutOptionals, FieldSelector.ALL_FIELDS); assertThat(fields.isSelected(FieldSelector.Field.CLIENT_IP)).isFalse(); assertThat(fields.isSelected(FieldSelector.Field.CLIENT_PORT)).isFalse(); assertThat(fields.isSelected(FieldSelector.Field.BATCH_ID)).isFalse(); assertThat(fields.isSelected(FieldSelector.Field.SUBJECT)).isFalse(); }
static FieldSelector getFieldsAvailableInRecord(AuditRecord auditRecord, FieldSelector configuredFields) { FieldSelector fields = configuredFields; if (!auditRecord.getBatchId().isPresent()) { fields = fields.withoutField(FieldSelector.Field.BATCH_ID); } if (!auditRecord.getSubject().isPresent()) { fields = fields.withoutField(FieldSelector.Field.SUBJECT); } if (auditRecord.getClientAddress() == null) { fields = fields.withoutField(FieldSelector.Field.CLIENT_IP).withoutField(FieldSelector.Field.CLIENT_PORT); } return fields; }
FieldFilterFlavorAdapter { static FieldSelector getFieldsAvailableInRecord(AuditRecord auditRecord, FieldSelector configuredFields) { FieldSelector fields = configuredFields; if (!auditRecord.getBatchId().isPresent()) { fields = fields.withoutField(FieldSelector.Field.BATCH_ID); } if (!auditRecord.getSubject().isPresent()) { fields = fields.withoutField(FieldSelector.Field.SUBJECT); } if (auditRecord.getClientAddress() == null) { fields = fields.withoutField(FieldSelector.Field.CLIENT_IP).withoutField(FieldSelector.Field.CLIENT_PORT); } return fields; } }
FieldFilterFlavorAdapter { static FieldSelector getFieldsAvailableInRecord(AuditRecord auditRecord, FieldSelector configuredFields) { FieldSelector fields = configuredFields; if (!auditRecord.getBatchId().isPresent()) { fields = fields.withoutField(FieldSelector.Field.BATCH_ID); } if (!auditRecord.getSubject().isPresent()) { fields = fields.withoutField(FieldSelector.Field.SUBJECT); } if (auditRecord.getClientAddress() == null) { fields = fields.withoutField(FieldSelector.Field.CLIENT_IP).withoutField(FieldSelector.Field.CLIENT_PORT); } return fields; } private  FieldFilterFlavorAdapter(); }
FieldFilterFlavorAdapter { static FieldSelector getFieldsAvailableInRecord(AuditRecord auditRecord, FieldSelector configuredFields) { FieldSelector fields = configuredFields; if (!auditRecord.getBatchId().isPresent()) { fields = fields.withoutField(FieldSelector.Field.BATCH_ID); } if (!auditRecord.getSubject().isPresent()) { fields = fields.withoutField(FieldSelector.Field.SUBJECT); } if (auditRecord.getClientAddress() == null) { fields = fields.withoutField(FieldSelector.Field.CLIENT_IP).withoutField(FieldSelector.Field.CLIENT_PORT); } return fields; } private  FieldFilterFlavorAdapter();  }
FieldFilterFlavorAdapter { static FieldSelector getFieldsAvailableInRecord(AuditRecord auditRecord, FieldSelector configuredFields) { FieldSelector fields = configuredFields; if (!auditRecord.getBatchId().isPresent()) { fields = fields.withoutField(FieldSelector.Field.BATCH_ID); } if (!auditRecord.getSubject().isPresent()) { fields = fields.withoutField(FieldSelector.Field.SUBJECT); } if (auditRecord.getClientAddress() == null) { fields = fields.withoutField(FieldSelector.Field.CLIENT_IP).withoutField(FieldSelector.Field.CLIENT_PORT); } return fields; } private  FieldFilterFlavorAdapter();   }