11/*
2- * Copyright 2013, 2014 Deutsche Nationalbibliothek
2+ * Copyright 2013, 2020 Deutsche Nationalbibliothek and others
33 *
44 * Licensed under the Apache License, Version 2.0 the "License";
55 * you may not use this file except in compliance with the License.
1919import java .util .HashSet ;
2020import java .util .List ;
2121import java .util .Set ;
22+ import java .util .function .Supplier ;
2223
2324import org .metafacture .commons .StringUtil ;
2425import org .metafacture .flowcontrol .StreamBuffer ;
@@ -38,13 +39,17 @@ public final class Entity extends AbstractFlushingCollect {
3839 private final Set <NamedValueSource > sourcesLeft = new HashSet <NamedValueSource >();
3940 private final StreamBuffer buffer = new StreamBuffer ();
4041
41- private final Metamorph metamorph ;
42+ private final Supplier < StreamReceiver > receiver ;
4243
4344 private NamedValueSource nameSource ;
4445 private String currentName ;
4546
4647 public Entity (final Metamorph metamorph ) {
47- this .metamorph = metamorph ;
48+ this .receiver = () -> metamorph .getStreamReceiver ();
49+ }
50+
51+ public Entity (final StreamReceiver receiver ) {
52+ this .receiver = () -> receiver ;
4853 }
4954
5055 public void setNameSource (final NamedValueSource source ) {
@@ -60,7 +65,7 @@ protected void emit() {
6065 final Entity parent = (Entity ) namedValueReceiver ;
6166 parent .receive (null , null , this , getRecordCount (), getEntityCount ());
6267 } else {
63- write (metamorph . getStreamReceiver ());
68+ write (receiver . get ());
6469 }
6570 }
6671
0 commit comments