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

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

Introduction

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

Prototype

public static String reflectionToString(final Object object, final ToStringStyle style) 

Source Link

Document

Uses ReflectionToStringBuilder to generate a toString for the specified object.

Usage

From source file:VOBackupSumary.java

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

From source file:com.yougou.kaidian.user.service.impl.ApiKeyServiceImpl.java

@Transactional(rollbackFor = Exception.class)
@Override/*  w  ww . j a  v  a2s .co m*/
public boolean generateApiKeyAndBandingAndAuthorize(String merchantCode, ApiKey apiKey) throws Exception {
    boolean flag = false;
    try {
        //1 ?appkey
        this.saveApiKey(apiKey);
        //2 appkey
        ApiKeyMetadata metadata = new ApiKeyMetadata();
        metadata.setId(UUIDGenerator.getUUID());
        metadata.setKeyId(apiKey.getId());
        metadata.setMetadataKey("MERCHANTS");
        metadata.setMetadataVal(merchantCode);
        this.bindingApiKeyToMerchant(metadata);
        //3 ?appkey
        List<ApiLicense> licenses = new ArrayList<ApiLicense>();
        ApiLicense license = null;
        for (String apiId : UserConstant.APIIDS) {
            license = new ApiLicense();
            license.setId(UUIDGenerator.getUUID());
            license.setApiId(apiId);
            license.setKeyId(apiKey.getId());
            license.setLicensed(new Date());
            license.setLicensor(merchantCode);
            licenses.add(license);
        }
        this.authorizeApiKeyToMerchant(licenses);
        flag = true;
    } catch (Exception e) {
        logger.error("{}appkey{}?",
                new Object[] { merchantCode,
                        ToStringBuilder.reflectionToString(apiKey, ToStringStyle.SHORT_PREFIX_STYLE), e });
        throw new Exception("appkey??", e);
    }
    return flag;
}

From source file:cherry.foundation.springmvc.OperationLogHandlerInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {

    Principal principal = request.getUserPrincipal();
    if (principal == null) {
        SecurityContext context = SecurityContextHolder.getContext();
        if (context != null) {
            principal = context.getAuthentication();
        }/*ww w  . j  a v  a  2  s .c  o m*/
    }
    if (principal != null) {
        MDC.put(LOGIN_ID, principal.getName());
    }

    StringBuilder builder = createBasicInfo(request);

    builder.append(" {");
    boolean first = true;
    for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {

        String key = entry.getKey();
        String lkey = key.toLowerCase();
        String[] val = entry.getValue();

        if (!first) {
            builder.append(", ");
        }
        first = false;
        builder.append(key).append(": ");
        if (lkey.contains("password")) {
            builder.append("<MASKED>");
        } else {
            builder.append(ToStringBuilder.reflectionToString(val, ToStringStyle.SIMPLE_STYLE));
        }

        for (int i = 0; i < paramPattern.size(); i++) {
            if (paramPattern.get(i).matcher(lkey).matches()) {
                if (val != null && val.length == 1) {
                    MDC.put(paramMdcKey.get(i), val[0]);
                } else {
                    MDC.put(paramMdcKey.get(i),
                            ToStringBuilder.reflectionToString(val, ToStringStyle.SIMPLE_STYLE));
                }
            }
        }
    }
    builder.append("}");

    loggerEnter.info(builder.toString());

    return true;
}

From source file:com.tesshu.subsonic.client.sample4_music_andmovie.StreamPlayMovieApplication.java

@Override
public void start(Stage stage) throws Exception {

    Search2Controller search2 = context.getBean(Search2Controller.class);

    StreamController streamController = context.getBean(StreamController.class);

    SuccessObserver callback = context.getBean(SuccessObserver.class);

    SearchResult2 result2 = search2.get("CORPSE BRIDE", // query, required = true
            0, // artistCount, required = false
            null, // artistOffset, required = false
            0, // albumCount, required = false
            null, // albumOffset, required = false
            10, // songCount, required = false
            null, // songOffset, required = false
            null // musicFolderId, required = false
    );//from   w  ww .ja v  a  2  s.c o  m

    Child movie = result2.getSongs().stream().filter(child -> MediaType.VIDEO == child.getType())
            .filter(child -> format.equals(child.getSuffix())).collect(Collectors.toSet()).iterator().next();

    LOG.info(ToStringBuilder.reflectionToString(movie, ToStringStyle.MULTI_LINE_STYLE));

    // not valid?(Perhaps, I have not done convert setting on the server side)
    @SuppressWarnings("unused")
    String size = Integer.toString(movie.getOriginalWidth()) + "x"
            + Integer.toString(movie.getOriginalHeight());

    final IRequestUriObserver uriCallBack = (subject, uri) -> {
        uriStr = uri.toString();
    };

    streamController.stream(

            movie, // id
            null, // maxBitRate
            format, // format
            null, // timeOffset
            null, // size
            true, // estimateContentLength
            false, // converted
            null, // streamCallback
            uriCallBack, callback);

    Group root = new Group();
    Scene scene = new Scene(root, movie.getOriginalWidth(), movie.getOriginalHeight());
    Media media = new Media(uriStr);
    media.errorProperty().addListener((observable, old, cur) -> {
        LOG.info(cur + " : " + uriStr);
    });

    MediaPlayer player = new MediaPlayer(media);
    player.statusProperty().addListener((observable, old, cur) -> {
        LOG.info(cur + " : " + uriStr);
    });

    MediaView view = new MediaView(player);
    ((Group) scene.getRoot()).getChildren().add(view);
    stage.setScene(scene);
    stage.show();
    player.play();

}

From source file:com.jkoolcloud.tnt4j.streams.parsers.ActivityJavaObjectParser.java

@Override
protected String getRawDataAsMessage(Object data) {
    return ToStringBuilder.reflectionToString(data, ToStringStyle.MULTI_LINE_STYLE);
}

From source file:com.lithium.flow.filer.lucene.RecordDoc.java

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

From source file:net.dontdrinkandroot.lastfm.api.model.Scrobble.java

@Override
public String toString() {

    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}

From source file:com.amossys.hooker.hookers.Hooker.java

protected String getStringRepresentationOfAttribute(Object arg) {
    String argValue = null;/*  ww w . ja va  2 s . c om*/
    /**
     * If the class of the argument (or one of its father) redefined the toString method, we use it,
     * if not, we use ToStringBuilder.reflectionToString() to infer it
     */
    try {
        if (arg.getClass().getMethod("toString").getDeclaringClass().equals(Object.class)) {
            argValue = ToStringBuilder.reflectionToString(arg, ToStringStyle.SHORT_PREFIX_STYLE);
        } else {
            argValue = arg.toString();
        }
    } catch (NoSuchMethodException e) {
        SubstrateMain.log("The attribute of object " + arg + " has no toString method defined.", e);
    }
    return argValue;
}

From source file:io.wcm.handler.link.Link.java

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

From source file:com.glaf.oa.assesscontent.model.Assesscontent.java

@Override
public String toString() {

    return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}