Skip to content

Commit 923955c

Browse files
authored
Merge pull request #327 from metafacture/entity
Add constructor to allow Entity creation w/o Metamorph
2 parents 8b6652f + 95b24fe commit 923955c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

metamorph/src/main/java/org/metafacture/metamorph/DefaultErrorHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class DefaultErrorHandler implements MorphErrorHandler {
2929
@Override
3030
public void error(final Exception exception) {
3131
throw new MetamorphException(
32-
"Error while exectuing the Metamorph transformation pipeline: " +
32+
"Error while executing the Metamorph transformation pipeline: " +
3333
exception.getMessage(), exception);
3434
}
3535

metamorph/src/main/java/org/metafacture/metamorph/Entity.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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.
@@ -19,6 +19,7 @@
1919
import java.util.HashSet;
2020
import java.util.List;
2121
import java.util.Set;
22+
import java.util.function.Supplier;
2223

2324
import org.metafacture.commons.StringUtil;
2425
import 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

Comments
 (0)