Search in sources :

Example 26 with ToStringBuilder

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());
}
Also used : ToStringBuilder(org.eclipse.xtext.xbase.lib.util.ToStringBuilder) Test(org.junit.Test)

Example 27 with ToStringBuilder

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());
}
Also used : ToStringBuilder(org.eclipse.xtext.xbase.lib.util.ToStringBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ToString(org.eclipse.xtend.lib.annotations.ToString) Test(org.junit.Test)

Example 28 with ToStringBuilder

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());
}
Also used : ToStringBuilder(org.eclipse.xtext.xbase.lib.util.ToStringBuilder) Test(org.junit.Test)

Example 29 with ToStringBuilder

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());
}
Also used : ToStringBuilder(org.eclipse.xtext.xbase.lib.util.ToStringBuilder) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 30 with ToStringBuilder

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());
}
Also used : ToStringBuilder(org.eclipse.xtext.xbase.lib.util.ToStringBuilder) Test(org.junit.Test)

Aggregations

ToStringBuilder (org.eclipse.xtext.xbase.lib.util.ToStringBuilder)51 Pure (org.eclipse.xtext.xbase.lib.Pure)15 Test (org.junit.Test)11 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)7 ToString (org.eclipse.xtend.lib.annotations.ToString)1