use of org.eclipse.xtext.xbase.lib.util.ToStringBuilder in project xtext-lib by eclipse.
the class ToStringHelperTest method testHideFieldNames.
@Test
public void testHideFieldNames() {
ToStringHelperTest.MyEntity _myEntity = new ToStringHelperTest.MyEntity();
final ToStringBuilder helper = new ToStringBuilder(_myEntity).singleLine().hideFieldNames().addAllFields();
Assert.assertEquals("MyEntity [true, 42, ArrayList (\"foo\",\"bar\",\"baz\"), null, CLASS]", helper.toString());
}
use of org.eclipse.xtext.xbase.lib.util.ToStringBuilder in project xtext-lib by eclipse.
the class ToStringBuilderTest method recursionHandling.
@Test
public void recursionHandling() {
final ToStringBuilderTest.OtherClass obj = new ToStringBuilderTest.OtherClass();
obj.name = "foo";
obj.other = obj;
final ToStringBuilder builder = new ToStringBuilder(obj).addDeclaredFields();
StringConcatenation _builder = new StringConcatenation();
_builder.append("OtherClass [");
_builder.newLine();
_builder.append(" ");
_builder.append("other = ");
String _string = obj.toString();
_builder.append(_string, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("name = \"foo\"");
_builder.newLine();
_builder.append("]");
Assert.assertEquals(ToStringBuilderTest.toUnix(_builder.toString()), builder.toString());
}
use of org.eclipse.xtext.xbase.lib.util.ToStringBuilder in project xtext-lib by eclipse.
the class ToStringBuilderTest method testHideFieldNames.
@Test
public void testHideFieldNames() {
ToStringBuilderTest.MyEntity _myEntity = new ToStringBuilderTest.MyEntity();
final ToStringBuilder builder = new ToStringBuilder(_myEntity).singleLine().hideFieldNames().addAllFields();
Assert.assertEquals("MyEntity [true, 42, ArrayList (\"foo\",\"bar\",\"baz\"), null, CLASS]", builder.toString());
}
use of org.eclipse.xtext.xbase.lib.util.ToStringBuilder in project xtext-lib by eclipse.
the class ToStringBuilderTest method recursionHandling_02.
@Test
public void recursionHandling_02() {
final ToStringBuilderTest.DataClass obj = new ToStringBuilderTest.DataClass();
obj.other = obj;
obj.name = "test";
final ToStringBuilder builder = new ToStringBuilder(obj).addDeclaredFields();
StringConcatenation _builder = new StringConcatenation();
_builder.append("DataClass [");
_builder.newLine();
_builder.append(" ");
_builder.append("other = DataClass@");
int _identityHashCode = System.identityHashCode(obj);
_builder.append(_identityHashCode, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("name = \"test\"");
_builder.newLine();
_builder.append("]");
Assert.assertEquals(ToStringBuilderTest.toUnix(_builder.toString()), builder.toString());
}
use of org.eclipse.xtext.xbase.lib.util.ToStringBuilder in project xtext-lib by eclipse.
the class ToStringBuilderTest method testSingleLine.
@Test
public void testSingleLine() {
ToStringBuilderTest.MyEntity _myEntity = new ToStringBuilderTest.MyEntity();
final ToStringBuilder builder = new ToStringBuilder(_myEntity).singleLine().addAllFields();
Assert.assertEquals("MyEntity [boolProp = true, intProp = 42, myList = ArrayList (\"foo\",\"bar\",\"baz\"), friend = null, policy = CLASS]", builder.toString());
}
Aggregations