1
1
/*
2
- * Copyright 2013, 2014 Deutsche Nationalbibliothek
2
+ * Copyright 2013, 2020 Deutsche Nationalbibliothek and others
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 the "License";
5
5
* you may not use this file except in compliance with the License.
19
19
import java .util .HashSet ;
20
20
import java .util .List ;
21
21
import java .util .Set ;
22
+ import java .util .function .Supplier ;
22
23
23
24
import org .metafacture .commons .StringUtil ;
24
25
import org .metafacture .flowcontrol .StreamBuffer ;
@@ -38,13 +39,17 @@ public final class Entity extends AbstractFlushingCollect {
38
39
private final Set <NamedValueSource > sourcesLeft = new HashSet <NamedValueSource >();
39
40
private final StreamBuffer buffer = new StreamBuffer ();
40
41
41
- private final Metamorph metamorph ;
42
+ private final Supplier < StreamReceiver > receiver ;
42
43
43
44
private NamedValueSource nameSource ;
44
45
private String currentName ;
45
46
46
47
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 ;
48
53
}
49
54
50
55
public void setNameSource (final NamedValueSource source ) {
@@ -60,7 +65,7 @@ protected void emit() {
60
65
final Entity parent = (Entity ) namedValueReceiver ;
61
66
parent .receive (null , null , this , getRecordCount (), getEntityCount ());
62
67
} else {
63
- write (metamorph . getStreamReceiver ());
68
+ write (receiver . get ());
64
69
}
65
70
}
66
71
0 commit comments