Example usage for org.apache.commons.lang.builder ToStringBuilder reflectionToString

List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString

Introduction

In this page you can find the example usage for org.apache.commons.lang.builder ToStringBuilder reflectionToString.

Prototype

public static String reflectionToString(Object object, ToStringStyle style) 

Source Link

Document

Forwards to ReflectionToStringBuilder.

Usage

From source file:com.gemini.mapper.ProtocolCustomConverter.java

@Override
public Object convert(Object destValue, Object sourceValue, Class<?> destinationClass, Class<?> sourceClass) {
    if (sourceValue == null) {
        Logger.error("Protocol Custom Converter used incorrectly, NULL values passed");
        return null;
    }//from   ww w  .ja v  a2 s. c  om
    if (sourceValue instanceof String) {
        //convert String to GeminiEnvironmentType
        for (Protocol protocol : Protocol.values()) {
            if (protocol.name().equals((String) sourceValue)) {
                return protocol;
            }
        }
    } else if (sourceValue instanceof Protocol) {
        return ((Protocol) sourceValue).name();
    } else {
        Logger.error(
                "Protocol Custom Converter used incorrectly. Arguments passed in were: source\n {} \n destination\n {}",
                ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE),
                ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE));
        throw new MappingException("Protocol Converter used incorrectly. Arguments passed in were:"
                + ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE) + " and "
                + ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE));
    }
    return null;
}

From source file:acromusashi.stream.camel.debug.ExchangeDumper.java

/**
 * Exchange?debug/*from   w  w  w.  jav  a 2s .c  o m*/
 * 
 * @param exchange debug?Exchange
 * @throws IOException 
 */
public void dump(Exchange exchange) throws IOException {
    if (logger.isDebugEnabled()) {
        logger.debug(ToStringBuilder.reflectionToString(exchange.getIn().getBody(),
                ToStringStyle.SHORT_PREFIX_STYLE));
    }
}

From source file:au.id.hazelwood.xmltvguidebuilder.framework.BaseObject.java

@Override
public final String toString() {
    return ToStringBuilder.reflectionToString(this, getToStringStyle());
}

From source file:com.gemini.common.repository.impl.BaseRepositoryMongoDBImpl.java

@Override
public List<T> list() {
    Logger.debug("list-find:{}",
            ToStringBuilder.reflectionToString(type.getSimpleName(), ToStringStyle.MULTI_LINE_STYLE));
    return getDatastore().createQuery(type).asList();
}

From source file:com.iorga.webappwatcher.eventlog.EventLog.java

@Override
public String toString() {
    return ToStringBuilder.reflectionToString(this, TO_STRING_STYLE);
}

From source file:com.gemini.mapper.EnvironmentTypeCustomConverter.java

@Override
public Object convert(Object destValue, Object sourceValue, Class<?> destinationClass, Class<?> sourceClass) {
    if (sourceValue == null) {
        Logger.error("Environment Type Custom Converter used incorrectly, NULL values passed");
        return null;
    }//w ww  . j  a  v  a  2s.c o m
    if (sourceValue instanceof String) {
        //convert String to GeminiEnvironmentType
        for (GeminiEnvironmentType envType : GeminiEnvironmentType.values()) {
            if (envType.name().equals((String) sourceValue)) {
                return envType;
            }
        }
    } else if (sourceValue instanceof InetAddress) {
        return ((GeminiEnvironmentType) sourceValue).name();
    } else {
        Logger.error(
                "IP Address Custom Converter used incorrectly. Arguments passed in were: source\n {} \n destination\n {}",
                ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE),
                ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE));
        throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
                + ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE) + " and "
                + ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE));
    }
    return null;
}

From source file:com.gemini.mapper.URLCustomConverter.java

@Override
public Object convert(Object destValue, Object sourceValue, Class<?> destinationClass, Class<?> sourceClass) {
    if (sourceValue == null) {
        Logger.error("URL Custom Converter used incorrectly, NULL values passed");
        return null;
    }/*  w  w w . ja v  a  2s . c o m*/
    if (sourceValue instanceof String) {
        try {
            //convert String to URL
            URL url = new URL((String) sourceValue);
            return url;
        } catch (MalformedURLException ex) {
            Logger.info("URL Custom Converter used incorrectly, invalid URL supplied as source: {}",
                    (String) sourceValue);
        }
    } else if (sourceValue instanceof URL) {
        return ((URL) sourceValue).toString();
    } else {
        Logger.error(
                "URL Custom Converterr used incorrectly. Arguments passed in were: source\n {} \n destination\n {}",
                ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE),
                ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE));
        throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
                + ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE) + " and "
                + ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE));
    }
    return null;
}

From source file:ReflectionBuilderTrial.java

public String toString() {
    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}

From source file:com.gemini.domain.repository.impl.GeminiNetworkRepositoryMongoDBImpl.java

public GeminiNetwork getNetByStartAndEnd(String start, String end) {
    Datastore ds = getDatastore();//  w w w.ja v a  2 s.c om
    if (ds == null) {
        Logger.error("get networks by start and end - no datastore:{} to {}", start, end);
        return null;
    }

    Logger.debug("get networks by start and end - build query", ToStringBuilder
            .reflectionToString(this.getClass().getSimpleName(), ToStringStyle.MULTI_LINE_STYLE));

    List<GeminiNetwork> retList = ds.find(GeminiNetwork.class).filter("start", InetAddresses.forString(start))
            .filter("end", InetAddresses.forString(end)).asList();
    for (GeminiNetwork n : retList) {
        //return the first one in the list
        Logger.debug("get networks by start and end - found networks:{} to {}", start, end);
        return n;
    }
    Logger.debug("get networks by start and end - did not find the networks:{} to {}", start, end);
    return null;
}

From source file:com.gemini.mapper.IPAddressTypeCustomConverter.java

@Override
public Object convert(Object destValue, Object sourceValue, Class<?> destinationClass, Class<?> sourceClass) {
    if (sourceValue == null) {
        Logger.error("IP Address Type Custom Converter used incorrectly, NULL values passed");
        return null;
    }//from ww  w .  j a v a  2 s .c  o  m
    if (sourceValue instanceof String) {
        //convert String to GeminiEnvironmentType
        for (IPAddressType envType : IPAddressType.values()) {
            if (envType.name().equals((String) sourceValue)) {
                return envType;
            }
        }
        Logger.error("IP Address Type converter used incorrectly - invalid address type {}",
                (String) sourceValue);
    } else if (sourceValue instanceof IPAddressType) {
        return ((IPAddressType) sourceValue).name();
    } else {
        Logger.error(
                "IP Address Custom Converter used incorrectly. Arguments passed in were: source\n {} \n destination\n {}",
                ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE),
                ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE));
        throw new MappingException("Converter TestCustomConverter used incorrectly. Arguments passed in were:"
                + ToStringBuilder.reflectionToString(destValue, ToStringStyle.MULTI_LINE_STYLE) + " and "
                + ToStringBuilder.reflectionToString(sourceValue, ToStringStyle.MULTI_LINE_STYLE));
    }
    return null;
}