/** * <p>Returns the number of inheritance hops between two classes.</p> * * @param child the child class, may be {@code null} * @param parent the parent class, may be {@code null} * @return the number of generations between the child and parent; 0 if the same class; * -1 if the classes are not related as child and parent (includes where either class is null) * @since 3.2 */ public static int distance(final Class<?> child, final Class<?> parent) { if (child == null || parent == null) { return -1; } if (child.equals(parent)) { return 0; } final Class<?> cParent = child.getSuperclass(); int d = BooleanUtils.toInteger(parent.equals(cParent)); if (d == 1) { return d; } d += distance(cParent, parent); return d > 0 ? d + 1 : -1; } }
@Override public int sessionCount() { return BooleanUtils.toInteger(this.supportRegistryState, this.ticketGrantingTicketsCache .getKeysWithExpiryCheck().size(), super.sessionCount()); }
@Override public int serviceTicketCount() { return BooleanUtils.toInteger(this.supportRegistryState, this.serviceTicketsCache.getKeysWithExpiryCheck() .size(), super.serviceTicketCount()); } }
/** * <p>Returns the number of inheritance hops between two classes.</p> * * @param child the child class, may be {@code null} * @param parent the parent class, may be {@code null} * @return the number of generations between the child and parent; 0 if the same class; * -1 if the classes are not related as child and parent (includes where either class is null) * @since 3.2 */ public static int distance(final Class<?> child, final Class<?> parent) { if (child == null || parent == null) { return -1; } if (child.equals(parent)) { return 0; } final Class<?> cParent = child.getSuperclass(); int d = BooleanUtils.toInteger(parent.equals(cParent)); if (d == 1) { return d; } d += distance(cParent, parent); return d > 0 ? d + 1 : -1; } }
/** * <p>Returns the number of inheritance hops between two classes.</p> * * @param child the child class, may be {@code null} * @param parent the parent class, may be {@code null} * @return the number of generations between the child and parent; 0 if the same class; * -1 if the classes are not related as child and parent (includes where either class is null) * @since 3.2 */ public static int distance(final Class<?> child, final Class<?> parent) { if (child == null || parent == null) { return -1; } if (child.equals(parent)) { return 0; } final Class<?> cParent = child.getSuperclass(); int d = BooleanUtils.toInteger(parent.equals(cParent)); if (d == 1) { return d; } d += distance(cParent, parent); return d > 0 ? d + 1 : -1; } }
/** * <p>Returns the number of inheritance hops between two classes.</p> * * @param child the child class, may be {@code null} * @param parent the parent class, may be {@code null} * @return the number of generations between the child and parent; 0 if the same class; * -1 if the classes are not related as child and parent (includes where either class is null) * @since 3.2 */ public static int distance(final Class<?> child, final Class<?> parent) { if (child == null || parent == null) { return -1; } if (child.equals(parent)) { return 0; } final Class<?> cParent = child.getSuperclass(); int d = BooleanUtils.toInteger(parent.equals(cParent)); if (d == 1) { return d; } d += distance(cParent, parent); return d > 0 ? d + 1 : -1; } }
@Override public JsonElement serialize(WxMpMaterialNews.WxMpMaterialNewsArticle article, Type typeOfSrc, JsonSerializationContext context) { JsonObject articleJson = new JsonObject(); articleJson.addProperty("thumb_media_id", article.getThumbMediaId()); articleJson.addProperty("thumb_url", article.getThumbUrl()); articleJson.addProperty("title", article.getTitle()); articleJson.addProperty("content", article.getContent()); if (null != article.getAuthor()) { articleJson.addProperty("author", article.getAuthor()); } if (null != article.getContentSourceUrl()) { articleJson.addProperty("content_source_url", article.getContentSourceUrl()); } if (null != article.getDigest()) { articleJson.addProperty("digest", article.getDigest()); } articleJson.addProperty("show_cover_pic", article.isShowCoverPic() ? "1" : "0"); if (null != article.getUrl()) { articleJson.addProperty("url", article.getUrl()); } if (null != article.getNeedOpenComment()) { articleJson.addProperty("need_open_comment", BooleanUtils.toInteger(article.getNeedOpenComment(), 1, 0)); } if (null != article.getOnlyFansCanComment()) { articleJson.addProperty("only_fans_can_comment", BooleanUtils.toInteger(article.getOnlyFansCanComment(), 1, 0)); } return articleJson; }
@Override public JsonElement serialize(WxMpMaterialNews.WxMpMaterialNewsArticle article, Type typeOfSrc, JsonSerializationContext context) { JsonObject articleJson = new JsonObject(); articleJson.addProperty("thumb_media_id", article.getThumbMediaId()); articleJson.addProperty("thumb_url", article.getThumbUrl()); articleJson.addProperty("title", article.getTitle()); articleJson.addProperty("content", article.getContent()); if (null != article.getAuthor()) { articleJson.addProperty("author", article.getAuthor()); } if (null != article.getContentSourceUrl()) { articleJson.addProperty("content_source_url", article.getContentSourceUrl()); } if (null != article.getDigest()) { articleJson.addProperty("digest", article.getDigest()); } articleJson.addProperty("show_cover_pic", article.isShowCoverPic() ? "1" : "0"); if (null != article.getUrl()) { articleJson.addProperty("url", article.getUrl()); } if (null != article.getNeedOpenComment()) { articleJson.addProperty("need_open_comment", BooleanUtils.toInteger(article.getNeedOpenComment(), 1, 0)); } if (null != article.getOnlyFansCanComment()) { articleJson.addProperty("only_fans_can_comment", BooleanUtils.toInteger(article.getOnlyFansCanComment(), 1, 0)); } return articleJson; }