Search in sources :

Example 61 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project cas by apereo.

the class AccessTokenGrantRequestAuditResourceResolver method resolveFrom.

@Override
public String[] resolveFrom(final JoinPoint auditableTarget, final Object retval) {
    Objects.requireNonNull(retval, "AccessTokenRequestDataHolder must not be null");
    final AccessTokenRequestDataHolder accessTokenRequest = AccessTokenRequestDataHolder.class.cast(retval);
    final String tokenId = accessTokenRequest.getToken() == null ? "N/A" : accessTokenRequest.getToken().getId();
    final String result = new ToStringBuilder(this, NO_CLASS_NAME_STYLE).append("oauth_token", tokenId).append("client_id", accessTokenRequest.getRegisteredService().getClientId()).append("client_service", accessTokenRequest.getService().getId()).append("grant_type", accessTokenRequest.getGrantType().getType()).append("scopes", accessTokenRequest.getScopes()).toString();
    return new String[] { result };
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) AccessTokenRequestDataHolder(org.apereo.cas.support.oauth.web.response.accesstoken.ext.AccessTokenRequestDataHolder)

Example 62 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project commons-lang by apache.

the class JsonToStringStyleTest method testArray.

@Test
public void testArray() {
    final Person p = new Person();
    p.name = "Jane Doe";
    p.age = 25;
    p.smoker = true;
    assertEquals("{\"name\":\"Jane Doe\",\"age\":25,\"smoker\":true,\"groups\":['admin', 'manager', 'user']}", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).append("groups", new Object() {

        @Override
        public String toString() {
            return "['admin', 'manager', 'user']";
        }
    }).toString());
}
Also used : Person(org.apache.commons.lang3.builder.ToStringStyleTest.Person) Test(org.junit.Test)

Example 63 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project commons-lang by apache.

the class JsonToStringStyleTest method testPerson.

@Test
public void testPerson() {
    final Person p = new Person();
    p.name = "Jane Doe";
    p.age = 25;
    p.smoker = true;
    assertEquals("{\"name\":\"Jane Doe\",\"age\":25,\"smoker\":true}", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
Also used : Person(org.apache.commons.lang3.builder.ToStringStyleTest.Person) Test(org.junit.Test)

Example 64 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project commons-lang by apache.

the class SimpleToStringStyleTest method testPerson.

@Test
public void testPerson() {
    final Person p = new Person();
    p.name = "Jane Q. Public";
    p.age = 47;
    p.smoker = false;
    assertEquals("Jane Q. Public,47,false", new ToStringBuilder(p).append("name", p.name).append("age", p.age).append("smoker", p.smoker).toString());
}
Also used : Person(org.apache.commons.lang3.builder.ToStringStyleTest.Person) Test(org.junit.Test)

Example 65 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project xwiki-platform by xwiki.

the class AbstractMailQueueItem method prepareToString.

protected ToStringBuilder prepareToString() {
    ToStringBuilder builder = new XWikiToStringBuilder(this);
    builder.append("batchId", getBatchId());
    return builder;
}
Also used : XWikiToStringBuilder(org.xwiki.text.XWikiToStringBuilder) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) XWikiToStringBuilder(org.xwiki.text.XWikiToStringBuilder)

Aggregations

ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)109 Person (org.apache.commons.lang3.builder.ToStringStyleTest.Person)10 Test (org.junit.Test)10 XWikiToStringBuilder (org.xwiki.text.XWikiToStringBuilder)7 Date (java.util.Date)3 Map (java.util.Map)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 StringUtils (org.apache.commons.lang3.StringUtils)2 ToStringStyle (org.apache.commons.lang3.builder.ToStringStyle)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Level (org.apache.logging.log4j.Level)2 LoggerContext (org.apache.logging.log4j.core.LoggerContext)2 FileAppender (org.apache.logging.log4j.core.appender.FileAppender)2 MemoryMappedFileAppender (org.apache.logging.log4j.core.appender.MemoryMappedFileAppender)2 RandomAccessFileAppender (org.apache.logging.log4j.core.appender.RandomAccessFileAppender)2 RollingFileAppender (org.apache.logging.log4j.core.appender.RollingFileAppender)2