Skip to content

Commit d577f0c

Browse files
Improvements to AbstractCoreInstanceWrapper (#1209)
* Add toString to AbstractCoreInstanceWrapper * Make AbstractCoreInstanceWrapper.instance final * Make AbstractCoreInstanceWrapper abstract and its constructor protected
1 parent c4f2c9c commit d577f0c

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

legend-pure-core/legend-pure-m4/src/main/java/org/finos/legend/pure/m4/coreinstance/AbstractCoreInstanceWrapper.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import org.finos.legend.pure.m4.exception.PureCompilationException;
2525
import org.finos.legend.pure.m4.transaction.ModelRepositoryTransaction;
2626

27-
public class AbstractCoreInstanceWrapper implements CoreInstance
27+
public abstract class AbstractCoreInstanceWrapper implements CoreInstance
2828
{
29-
protected CoreInstance instance;
29+
protected final CoreInstance instance;
3030

31-
public AbstractCoreInstanceWrapper(CoreInstance instance)
31+
protected AbstractCoreInstanceWrapper(CoreInstance instance)
3232
{
3333
this.instance = instance;
3434
}
@@ -355,4 +355,17 @@ public int hashCode()
355355
{
356356
return this.instance.hashCode();
357357
}
358+
359+
@Override
360+
public String toString()
361+
{
362+
StringBuilder builder = new StringBuilder(super.toString())
363+
.append('{').append(this.instance);
364+
SourceInformation sourceInfo = this.instance.getSourceInformation();
365+
if (sourceInfo != null)
366+
{
367+
sourceInfo.appendMessage(builder.append(" (")).append(')');
368+
}
369+
return builder.append('}').toString();
370+
}
358371
}

0 commit comments

Comments
 (0)