List of usage examples for org.apache.commons.lang3.builder ToStringBuilder reflectionToString
public static String reflectionToString(final Object object)
Uses ReflectionToStringBuilder
to generate a toString
for the specified object.
From source file:org.squashtest.tm.web.internal.controller.testautomation.TestAutomationServerController.java
@RequestMapping(value = "/new", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from w w w . java 2 s. co m*/ @ResponseBody public void createNew(@RequestBody NewTestAutomationServer server) { if (LOGGER.isInfoEnabled()) { // w/o this test string rep is always build LOGGER.info("Add new Test automation server : {}", ToStringBuilder.reflectionToString(server)); } service.persist(server.createTransientEntity()); }
From source file:org.squashtest.tm.web.internal.controller.users.TeamController.java
/** * Creates a new Team/*w w w. ja v a 2s . c o m*/ * * @param team * : the given {@link Team} filled with a name and a description */ @RequestMapping(value = "/new", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) @ResponseBody public void createNew(@Valid @ModelAttribute("add-team") Team team) { LOGGER.info(ToStringBuilder.reflectionToString(team)); service.persist(team); }
From source file:sx.blah.discord.api.internal.DispatchHandler.java
private void reactionAdd(ReactionEventResponse event) { IChannel channel = shard.getChannelByID(Long.parseUnsignedLong(event.channel_id)); if (channel == null) return;/* w ww .j av a 2 s .co m*/ if (!PermissionUtils.hasPermissions(channel, client.ourUser, Permissions.READ_MESSAGES, Permissions.READ_MESSAGE_HISTORY)) return; // Discord sends this event no matter our permissions for some reason. boolean cached = ((Channel) channel).messages.containsKey(Long.parseUnsignedLong(event.message_id)); IMessage message = channel.fetchMessage(Long.parseUnsignedLong(event.message_id)); if (message == null) { Discord4J.LOGGER.debug("Unable to fetch the message specified by a reaction add event\nObject={}", ToStringBuilder.reflectionToString(event)); return; } IReaction reaction = event.emoji.id == null ? message.getReactionByUnicode(event.emoji.name) : message.getReactionByID(Long.parseUnsignedLong(event.emoji.id)); message.getReactions().remove(reaction); if (reaction == null) { // Only happens in the case of a cached message with a new reaction long id = event.emoji.id == null ? 0 : Long.parseUnsignedLong(event.emoji.id); reaction = new Reaction(message, 1, ReactionEmoji.of(event.emoji.name, id)); } else if (cached) { reaction = new Reaction(message, reaction.getCount() + 1, reaction.getEmoji()); } message.getReactions().add(reaction); IUser user; if (channel.isPrivate()) { user = channel.getUsersHere().get( channel.getUsersHere().get(0).getLongID() == Long.parseUnsignedLong(event.user_id) ? 0 : 1); } else { user = channel.getGuild().getUserByID(Long.parseUnsignedLong(event.user_id)); } client.dispatcher.dispatch(new ReactionAddEvent(message, reaction, user)); }
From source file:sx.blah.discord.api.internal.DispatchHandler.java
private void reactionRemove(ReactionEventResponse event) { IChannel channel = shard.getChannelByID(Long.parseUnsignedLong(event.channel_id)); if (channel == null) return;/*from w ww . j a v a2 s. c o m*/ if (!PermissionUtils.hasPermissions(channel, client.ourUser, Permissions.READ_MESSAGES, Permissions.READ_MESSAGE_HISTORY)) return; // Discord sends this event no matter our permissions for some reason. boolean cached = ((Channel) channel).messages.containsKey(Long.parseUnsignedLong(event.message_id)); IMessage message = channel.fetchMessage(Long.parseUnsignedLong(event.message_id)); if (message == null) { Discord4J.LOGGER.debug("Unable to fetch the message specified by a reaction remove event\nObject={}", ToStringBuilder.reflectionToString(event)); return; } IReaction reaction = event.emoji.id == null ? message.getReactionByUnicode(event.emoji.name) : message.getReactionByID(Long.parseUnsignedLong(event.emoji.id)); message.getReactions().remove(reaction); if (reaction == null) { // the last reaction of the emoji was removed long id = event.emoji.id == null ? 0 : Long.parseUnsignedLong(event.emoji.id); reaction = new Reaction(message, 0, ReactionEmoji.of(event.emoji.name, id)); } else { reaction = new Reaction(message, !cached ? reaction.getCount() : reaction.getCount() - 1, reaction.getEmoji()); } if (reaction.getCount() > 0) { message.getReactions().add(reaction); } IUser user; if (channel.isPrivate()) { user = channel.getUsersHere().get( channel.getUsersHere().get(0).getLongID() == Long.parseUnsignedLong(event.user_id) ? 0 : 1); } else { user = channel.getGuild().getUserByID(Long.parseUnsignedLong(event.user_id)); } client.dispatcher.dispatch(new ReactionRemoveEvent(message, reaction, user)); }