Example usage for org.apache.commons.lang3 BooleanUtils toInteger

List of usage examples for org.apache.commons.lang3 BooleanUtils toInteger

Introduction

In this page you can find the example usage for org.apache.commons.lang3 BooleanUtils toInteger.

Prototype

public static int toInteger(final boolean bool) 

Source Link

Document

Converts a boolean to an int using the convention that zero is false .

 BooleanUtils.toInteger(true)  = 1 BooleanUtils.toInteger(false) = 0 

Usage

From source file:de.bmarwell.j9kwsolver.util.BooleanUtils10.java

/**
 * Returns a textual representation of 1 for true or 0 for false.
 * @param bool - a boolean./*from  w  w w. jav  a 2  s .  c o  m*/
 * @return either 0 or 1.
 */
public static String toIntegerString(final boolean bool) {
    int boolint = BooleanUtils.toInteger(bool);

    return Integer.toString(boolint);
}

From source file:mx.com.adolfogarcia.popularmovies.data.TestUtilities.java

/**
 * Returns the values of a row that may be inserted into the movie database.
 *
 * @return the values of a row that may be inserted into the movie database.
 *//*from   ww  w.  java2s.c o m*/
static ContentValues createMadMaxMovieValues() {
    ContentValues testValues = new ContentValues();
    testValues.put(CachedMovieEntry.COLUMN_API_ID, 76341);
    testValues.put(CachedMovieEntry.COLUMN_BACKDROP_PATH, "/tbhdm8UJAb4ViCTsulYFL3lxMCd.jpg");
    testValues.put(CachedMovieEntry.COLUMN_RELEASE_DATE, 1431648000000L);
    testValues.put(CachedMovieEntry.COLUMN_ORIGINAL_TITLE, "Mad Max: Fury Road");
    testValues.put(CachedMovieEntry.COLUMN_OVERVIEW, "An apocalyptic story...");
    testValues.put(CachedMovieEntry.COLUMN_POPULARITY, 55.32);
    testValues.put(CachedMovieEntry.COLUMN_POSTER_PATH, "/kqjL17yufvn9OVLyXYpvtyrFfak.jpg");
    testValues.put(CachedMovieEntry.COLUMN_VOTE_AVERAGE, 7.7);
    testValues.put(CachedMovieEntry.COLUMN_MOST_POPULAR, BooleanUtils.toInteger(true));
    testValues.put(CachedMovieEntry.COLUMN_HIGHEST_RATED, BooleanUtils.toInteger(false));
    testValues.put(CachedMovieEntry.COLUMN_USER_FAVORITE, BooleanUtils.toInteger(false));
    return testValues;
}

From source file:mx.com.adolfogarcia.popularmovies.net.FetchFavoriteMoviePageTaskFactory.java

@Override
public String[] getMovieProviderSelectionArguments() {
    return new String[] { Integer.toString(BooleanUtils.toInteger(true)) };
}

From source file:com.microfocus.application.automation.tools.lr.model.SummaryDataLogModel.java

public void addToProps(Properties props) {
    if (StringUtils.isEmpty(pollingInterval)) {
        pollingInterval = "30";
    }/*from  ww  w  .j av a  2s  .  co  m*/

    props.put("SummaryDataLog",
            BooleanUtils.toInteger(logVusersStates) + ";" + BooleanUtils.toInteger(logErrorCount) + ";"
                    + BooleanUtils.toInteger(logTransactionStatistics) + ";"
                    + Integer.parseInt(pollingInterval));
}

From source file:com.thinkbiganalytics.discovery.model.DefaultField.java

/**
 *
 * Returns the structure in the format: Name | DataType | Desc | Primary \ CreatedTracker | UpdatedTracker | otherName
 *
 * @param otherName the name of the related field in either the alternate (either source or target) table
 * @return/*  ww  w  . jav  a2 s . co m*/
 */
public String asFieldStructure(String otherName) {
    return name + "|" + getDataTypeWithPrecisionAndScale() + "|" + getDescriptionWithoutNewLines() + "|"
            + BooleanUtils.toInteger(primaryKey) + "|" + BooleanUtils.toInteger(createdTracker) + "|"
            + BooleanUtils.toInteger(updatedTracker) + "|" + StringUtils.trimToEmpty(otherName);
}

From source file:mx.com.adolfogarcia.popularmovies.model.view.MovieDetailViewModel.java

/**
 * Sets or removes the movie from the user's favorites, depending on
 * the value of {@link CheckBox#isChecked()}. This change is performed on
 * the {@code ContentProvider}./* ww w .ja v  a 2  s  .com*/
 *
 * @param checkBox the {@link CheckBox} that was clicked.
 */
public void onClickFavorite(CheckBox checkBox) {
    final boolean checked = checkBox.isChecked();
    if (checked == mMovie.isUserFavorite()) {
        Log.d(LOG_TAG, "Ignoring favorite change request. No change submitted.");
        return;
    }
    Context context = checkBox.getContext();
    ContentValues favoriteMovieValues = new ContentValues();
    favoriteMovieValues.put(CachedMovieEntry.COLUMN_USER_FAVORITE, BooleanUtils.toInteger(checked));
    int count = context.getContentResolver().update(CachedMovieEntry.CONTENT_URI, favoriteMovieValues,
            CachedMovieEntry._ID + "= ?", new String[] { Long.toString(mMovie.getId()) });
    if (count != 1) {
        Log.e(LOG_TAG, "Expected 1 movie to change favorite status, but got " + count);
    }
    mMovie.setUserFavorite(checked);
    notifyPropertyChanged(BR.favorite);
}

From source file:com.clustercontrol.collect.composite.CollectGraphComposite.java

/**
 * boolean?????????<br>//from  w  w  w.  j a va  2 s .  c  om
 * true  -> 1<br>
 * false -> 0<br>
 * @param booleanArr
 * @return
 */
private static String getBooleanString(boolean[] booleanArr) {
    StringBuffer booleanBuffer = new StringBuffer();
    for (boolean bool : booleanArr) {
        int str = BooleanUtils.toInteger(bool);
        booleanBuffer.append(str);
    }
    String retStr = booleanBuffer.toString();
    return retStr;
}

From source file:yoyo.framework.standard.shared.commons.lang.BooleanUtilsTest.java

@Test
public void test() {
    assertThat(BooleanUtils.and(new boolean[] { true }), is(true));
    assertThat(BooleanUtils.and(new boolean[] { true, false }), is(false));
    assertThat(BooleanUtils.isFalse(false), is(true));
    assertThat(BooleanUtils.isNotFalse(false), is(false));
    assertThat(BooleanUtils.isNotTrue(true), is(false));
    assertThat(BooleanUtils.isTrue(true), is(true));
    assertThat(BooleanUtils.negate(Boolean.FALSE), is(true));
    assertThat(BooleanUtils.or(new boolean[] { true }), is(true));
    assertThat(BooleanUtils.or(new boolean[] { true, false }), is(true));
    assertThat(BooleanUtils.toBoolean(Boolean.TRUE), is(true));
    assertThat(BooleanUtils.toBoolean(0), is(false));
    assertThat(BooleanUtils.toBoolean(1), is(true));
    assertThat(BooleanUtils.toBoolean((String) null), is(false));
    assertThat(BooleanUtils.toBoolean("true"), is(true));
    assertThat(BooleanUtils.toBoolean("hoge"), is(false));
    assertThat(BooleanUtils.toBooleanDefaultIfNull(null, false), is(false));
    assertThat(BooleanUtils.toBooleanObject(0), is(Boolean.FALSE));
    assertThat(BooleanUtils.toBooleanObject(1), is(Boolean.TRUE));
    assertThat(BooleanUtils.toInteger(true), is(1));
    assertThat(BooleanUtils.toInteger(false), is(0));
    assertThat(BooleanUtils.toIntegerObject(true), is(Integer.valueOf(1)));
    assertThat(BooleanUtils.toIntegerObject(false), is(Integer.valueOf(0)));
    assertThat(BooleanUtils.toString(true, "true", "false"), is("true"));
    assertThat(BooleanUtils.toString(false, "true", "false"), is("false"));
    assertThat(BooleanUtils.toStringOnOff(true), is("on"));
    assertThat(BooleanUtils.toStringOnOff(false), is("off"));
    assertThat(BooleanUtils.toStringTrueFalse(true), is("true"));
    assertThat(BooleanUtils.toStringTrueFalse(false), is("false"));
    assertThat(BooleanUtils.toStringYesNo(true), is("yes"));
    assertThat(BooleanUtils.toStringYesNo(false), is("no"));
    assertThat(BooleanUtils.xor(new boolean[] { true }), is(true));
    assertThat(BooleanUtils.xor(new boolean[] { true, false }), is(true));
    assertThat(BooleanUtils.xor(new boolean[] { true, true }), is(false));
}