Search in sources :

Example 46 with ToStringBuilder

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

the class NoClassNameToStringStyleTest method testPerson.

@Test
public void testPerson() {
    final Person p = new Person();
    p.name = "John Q. Public";
    p.age = 45;
    p.smoker = true;
    assertEquals("[name=John Q. Public,age=45,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 47 with ToStringBuilder

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

the class MailAddress method toString.

@Override
public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.JSON_STYLE);
    tsb.append("mailAddress", address);
    return tsb.build();
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder)

Example 48 with ToStringBuilder

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

the class LoggingConfigurationEndpoint method configuration.

/**
 * Configuration map.
 *
 * @return the map
 */
@ReadOperation
@Operation(summary = "Get logging configuration report")
public Map<String, Object> configuration() {
    val configuredLoggers = new HashSet<>();
    getLoggerConfigurations().forEach(config -> {
        val loggerMap = new HashMap<String, Object>();
        loggerMap.put("name", StringUtils.defaultIfBlank(config.getName(), LOGGER_NAME_ROOT));
        loggerMap.put("state", config.getState());
        if (config.getPropertyList() != null) {
            loggerMap.put("properties", config.getPropertyList());
        }
        loggerMap.put("additive", config.isAdditive());
        loggerMap.put("level", config.getLevel().name());
        val appenders = new HashSet<>();
        config.getAppenders().keySet().stream().map(key -> config.getAppenders().get(key)).forEach(appender -> {
            val builder = new ToStringBuilder(this, ToStringStyle.JSON_STYLE);
            builder.append("name", appender.getName());
            builder.append("state", appender.getState());
            builder.append("layoutFormat", appender.getLayout().getContentFormat());
            builder.append("layoutContentType", appender.getLayout().getContentType());
            if (appender instanceof FileAppender) {
                builder.append(FILE_PARAM, ((FileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RandomAccessFileAppender) {
                builder.append(FILE_PARAM, ((RandomAccessFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RollingFileAppender) {
                builder.append(FILE_PARAM, ((RollingFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, ((RollingFileAppender) appender).getFilePattern());
            }
            if (appender instanceof MemoryMappedFileAppender) {
                builder.append(FILE_PARAM, ((MemoryMappedFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RollingRandomAccessFileAppender) {
                builder.append(FILE_PARAM, ((RollingRandomAccessFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, ((RollingRandomAccessFileAppender) appender).getFilePattern());
            }
            appenders.add(builder.build());
        });
        loggerMap.put("appenders", appenders);
        configuredLoggers.add(loggerMap);
    });
    val responseMap = new HashMap<String, Object>();
    responseMap.put("loggers", configuredLoggers);
    val loggers = getActiveLoggersInFactory();
    responseMap.put("activeLoggers", loggers.values());
    return responseMap;
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) Getter(lombok.Getter) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) SneakyThrows(lombok.SneakyThrows) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerFactory(org.slf4j.LoggerFactory) ToStringStyle(org.apache.commons.lang3.builder.ToStringStyle) Level(org.apache.logging.log4j.Level) HashMap(java.util.HashMap) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) StringUtils(org.apache.commons.lang3.StringUtils) InitializingBean(org.springframework.beans.factory.InitializingBean) HashSet(java.util.HashSet) Operation(io.swagger.v3.oas.annotations.Operation) Pair(org.apache.commons.lang3.tuple.Pair) Configurator(org.apache.logging.log4j.core.config.Configurator) Map(java.util.Map) Log4jLoggerFactory(org.apache.logging.slf4j.Log4jLoggerFactory) Resource(org.springframework.core.io.Resource) ResourceUtils(org.apereo.cas.util.ResourceUtils) Logger(org.slf4j.Logger) ResourceLoader(org.springframework.core.io.ResourceLoader) Endpoint(org.springframework.boot.actuate.endpoint.annotation.Endpoint) lombok.val(lombok.val) Set(java.util.Set) BaseCasActuatorEndpoint(org.apereo.cas.web.BaseCasActuatorEndpoint) Parameter(io.swagger.v3.oas.annotations.Parameter) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) Slf4j(lombok.extern.slf4j.Slf4j) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) Environment(org.springframework.core.env.Environment) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Optional(java.util.Optional) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) ILoggerFactory(org.slf4j.ILoggerFactory) Selector(org.springframework.boot.actuate.endpoint.annotation.Selector) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) HashMap(java.util.HashMap) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) HashSet(java.util.HashSet) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation) WriteOperation(org.springframework.boot.actuate.endpoint.annotation.WriteOperation) Operation(io.swagger.v3.oas.annotations.Operation)

Example 49 with ToStringBuilder

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

the class ExternalParameterHandle method toString.

@Override
public String toString() {
    ToStringBuilder builder = new ToStringBuilder(this);
    builder.append("parameterNameShort", m_parameterNameShort);
    builder.append("parameterNameFullyQualified", m_parameterNameFullyQualified);
    builder.append("ownerNodeContainer", m_ownerNodeContainer);
    builder.append("parameterValue", m_parameterValue);
    return builder.build();
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder)

Example 50 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project iaf by ibissource.

the class JndiBase method toString.

public String toString() {
    ToStringBuilder ts = new ToStringBuilder(this);
    ts.append("context", context);
    ts.append("authentication", authentication);
    ts.append("credentials", credentials);
    ts.append("providerURL", providerURL);
    ts.append("urlPkgPrefixes", urlPkgPrefixes);
    ts.append("securityProtocol", securityProtocol);
    ts.append("initialContextFactoryName", initialContextFactoryName);
    return ts.toString();
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder)

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