Create Observable using just method in RxJava

Constructs a reactive type by taking a pre-existing object and emitting that specific object to the downstream consumer upon subscription.

Observable<String> observable = Observable.just("1");

observable.subscribe(s -> {
    System.out.println(s);
});
Observable<String> observable = Observable.just("1", "2", "3", "4");

observable.subscribe(s -> {
    System.out.println(s);
});

References
https://github.com/ReactiveX/RxJava/wiki/Creating-Observables#just

Create Observable using create method in RxJava

Construct a safe reactive type instance which when subscribed to by a consumer, runs an user-provided function and provides a type-specific Emitter for this function to generate the signal(s) the designated business logic requires. This method allows bridging the non-reactive, usually listener/callback-style world, with the reactive world.

Observable<String> observable = Observable.create(emitter -> {
    emitter.onNext("1");
    emitter.onNext("2");
    emitter.onComplete();
});

observable.subscribe(s -> {
    System.out.println(s);
});

References
https://www.vogella.com/tutorials/RxJava/article.html#creating-observables
https://www.tutorialspoint.com/rxjava/rxjava_creating_operators.htm
https://github.com/ReactiveX/RxJava/wiki/Creating-Observables#create

Detect Outlier using Boxplot in Java

import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
public boolean isOutlier(String itemId, String value) {

    if (monitoringItem.getProperties().getBoxPlotSize() > 0) {
        BoxPlot boxPlot = Statics.boxPlotRepository.findByItemId(itemId);

        DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics();
        double dValue = Double.parseDouble(value);

        for (ItemBoxPlot bItem : boxPlot.getBoxPlotList()) {
            double d = Double.parseDouble(bItem.getValue());

            descriptiveStatistics.addValue(d);
        }

        double Q1 = descriptiveStatistics.getPercentile(25);
        double Q3 = descriptiveStatistics.getPercentile(75);
        double IQR = Q3 - Q1;

        double highRange = Q3 + 3 * IQR;
        double lowRange = Q1 - 3 * IQR;

        if (dValue > highRange || dValue < lowRange) {
            return true;
        }
    }

    return false;
}

References
https://pupli.net/2019/05/31/detect-outlier-using-boxplot/

Declare a variable in Gradle usable in Java using buildConfigField and resValue

Generate Java Constants

android {
    buildTypes {
        debug {
            buildConfigField "int", "FOO", "42"
            buildConfigField "String", "FOO_STRING", "\"foo\""
            buildConfigField "boolean", "LOG", "true"
        }

        release {
            buildConfigField "int", "FOO", "52"
            buildConfigField "String", "FOO_STRING", "\"bar\""
            buildConfigField "boolean", "LOG", "false"
        }
    }
}

You can access them with BuildConfig.FOO

Generate Android resources

android {
    buildTypes {
        debug{
            resValue "string", "app_name", "My App Name Debug"
        }
        release {
            resValue "string", "app_name", "My App Name"
        }
    }
}

You can access them in the usual way with @string/app_name or R.string.app_name

String type build config fields should be declared like this:

buildConfigField "String", "SERVER_URL", "\"http://dev.myserver.com\""

References
https://stackoverflow.com/questions/17197636/is-it-possible-to-declare-a-variable-in-gradle-usable-in-java
https://stackoverflow.com/questions/30796533/how-to-generate-buildconfigfield-with-string-type