Tabnine Logo
BooleanUtils.toInteger
Code IndexAdd Tabnine to your IDE (free)

How to use
toInteger
method
in
org.apache.commons.lang3.BooleanUtils

Best Java code snippets using org.apache.commons.lang3.BooleanUtils.toInteger (Showing top 11 results out of 315)

origin: org.apache.commons/commons-lang3

  /**
   * <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;
  }
}
origin: org.apache.commons/commons-lang3

@Test
public void test_toInteger_Boolean_int_int_int() {
  assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8));
  assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8));
  assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8));
}
origin: org.apache.commons/commons-lang3

@Test
public void test_toInteger_boolean() {
  assertEquals(1, BooleanUtils.toInteger(true));
  assertEquals(0, BooleanUtils.toInteger(false));
}
origin: org.apache.commons/commons-lang3

@Test
public void test_toInteger_boolean_int_int() {
  assertEquals(6, BooleanUtils.toInteger(true, 6, 7));
  assertEquals(7, BooleanUtils.toInteger(false, 6, 7));
}
origin: org.jasig.cas/cas-server-integration-ehcache

@Override
public int sessionCount() {
  return BooleanUtils.toInteger(this.supportRegistryState, this.ticketGrantingTicketsCache
      .getKeysWithExpiryCheck().size(), super.sessionCount());
}
origin: org.jasig.cas/cas-server-integration-ehcache

  @Override
  public int serviceTicketCount() {
    return BooleanUtils.toInteger(this.supportRegistryState, this.serviceTicketsCache.getKeysWithExpiryCheck()
        .size(), super.serviceTicketCount());
  }
}
origin: io.virtdata/virtdata-lib-realer

  /**
   * <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;
  }
}
origin: io.virtdata/virtdata-lib-curves4

  /**
   * <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;
  }
}
origin: de.knightsoft-net/gwt-commons-lang3

  /**
   * <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;
  }
}
origin: com.github.binarywang/weixin-java-mp

@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;
}
origin: binarywang/WxJava

@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;
}
org.apache.commons.lang3BooleanUtilstoInteger

Javadoc

Converts a Boolean to an int specifying the conversion values.

 
BooleanUtils.toInteger(Boolean.TRUE, 1, 0, 2)  = 1 
BooleanUtils.toInteger(Boolean.FALSE, 1, 0, 2) = 0 
BooleanUtils.toInteger(null, 1, 0, 2)          = 2 

Popular methods of BooleanUtils

  • toBoolean
    Converts a String to a Boolean throwing an exception if no match found. BooleanUtils.toBoolean("t
  • isTrue
    Checks if a Boolean value is true, handling null by returning false. BooleanUtils.isTrue(Boolean.
  • toBooleanObject
    Converts a String to a Boolean throwing an exception if no match. NOTE: This returns null and will
  • isFalse
    Checks if a Boolean value is false, handling null by returning false. BooleanUtils.isFalse(Boolea
  • isNotTrue
    Checks if a Boolean value is not true, handling null by returning true. BooleanUtils.isNotTrue(Bo
  • toStringTrueFalse
    Converts a boolean to a String returning 'true'or 'false'. BooleanUtils.toStringTrueFalse(true)
  • toBooleanDefaultIfNull
    Converts a Boolean to a boolean handling null. BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE,
  • toString
    Converts a boolean to a String returning one of the input Strings. BooleanUtils.toString(true, "t
  • isNotFalse
    Checks if a Boolean value is not false, handling null by returning true. BooleanUtils.isNotFalse(
  • or
    Performs an or on a set of booleans. BooleanUtils.or(true, true) = true BooleanUtils.or
  • and
    Performs an and on a set of booleans. BooleanUtils.and(true, true) = true BooleanUtils.a
  • toStringYesNo
    Converts a boolean to a String returning 'yes'or 'no'. BooleanUtils.toStringYesNo(true) = "yes"
  • and,
  • toStringYesNo,
  • xor,
  • compare,
  • negate,
  • toStringOnOff,
  • <init>,
  • toIntegerObject

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • setRequestProperty (URLConnection)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JLabel (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Join (org.hibernate.mapping)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now