Use explicit constructor invocation ("this").

This commit is contained in:
Gilles 2016-05-14 01:03:54 +02:00
parent 412a8a0ba6
commit 0338025679
1 changed files with 19 additions and 24 deletions

View File

@ -26,6 +26,7 @@ import org.apache.commons.math4.exception.MathInternalError;
import org.apache.commons.math4.exception.NotANumberException;
import org.apache.commons.math4.random.RandomDataGenerator;
import org.apache.commons.math4.random.RandomGenerator;
import org.apache.commons.math4.random.Well19937c;
import org.apache.commons.math4.util.FastMath;
@ -88,10 +89,7 @@ public class NaturalRanking implements RankingAlgorithm {
* Create a NaturalRanking with default strategies for handling ties and NaNs.
*/
public NaturalRanking() {
super();
tiesStrategy = DEFAULT_TIES_STRATEGY;
nanStrategy = DEFAULT_NAN_STRATEGY;
randomData = null;
this(DEFAULT_NAN_STRATEGY, DEFAULT_TIES_STRATEGY, null);
}
/**
@ -100,10 +98,7 @@ public class NaturalRanking implements RankingAlgorithm {
* @param tiesStrategy the TiesStrategy to use
*/
public NaturalRanking(TiesStrategy tiesStrategy) {
super();
this.tiesStrategy = tiesStrategy;
nanStrategy = DEFAULT_NAN_STRATEGY;
randomData = new RandomDataGenerator();
this(DEFAULT_NAN_STRATEGY, tiesStrategy, new Well19937c());
}
/**
@ -112,10 +107,7 @@ public class NaturalRanking implements RankingAlgorithm {
* @param nanStrategy the NaNStrategy to use
*/
public NaturalRanking(NaNStrategy nanStrategy) {
super();
this.nanStrategy = nanStrategy;
tiesStrategy = DEFAULT_TIES_STRATEGY;
randomData = null;
this(nanStrategy, DEFAULT_TIES_STRATEGY, null);
}
/**
@ -125,10 +117,7 @@ public class NaturalRanking implements RankingAlgorithm {
* @param tiesStrategy TiesStrategy to use
*/
public NaturalRanking(NaNStrategy nanStrategy, TiesStrategy tiesStrategy) {
super();
this.nanStrategy = nanStrategy;
this.tiesStrategy = tiesStrategy;
randomData = new RandomDataGenerator();
this(nanStrategy, tiesStrategy, new Well19937c());
}
/**
@ -138,13 +127,9 @@ public class NaturalRanking implements RankingAlgorithm {
* @param randomGenerator source of random data
*/
public NaturalRanking(RandomGenerator randomGenerator) {
super();
this.tiesStrategy = TiesStrategy.RANDOM;
nanStrategy = DEFAULT_NAN_STRATEGY;
randomData = new RandomDataGenerator(randomGenerator);
this(DEFAULT_NAN_STRATEGY, TiesStrategy.RANDOM, randomGenerator);
}
/**
* Create a NaturalRanking with the given NaNStrategy, TiesStrategy.RANDOM
* and the given source of random data.
@ -153,10 +138,20 @@ public class NaturalRanking implements RankingAlgorithm {
* @param randomGenerator source of random data
*/
public NaturalRanking(NaNStrategy nanStrategy,
RandomGenerator randomGenerator) {
super();
RandomGenerator randomGenerator) {
this(nanStrategy, TiesStrategy.RANDOM, randomGenerator);
}
/**
* @param nanStrategy NaN strategy.
* @param randomGenerator RNG.
* @param tiesStrategy Tie strategy.
*/
private NaturalRanking(NaNStrategy nanStrategy,
TiesStrategy tiesStrategy,
RandomGenerator randomGenerator) {
this.nanStrategy = nanStrategy;
this.tiesStrategy = TiesStrategy.RANDOM;
this.tiesStrategy = tiesStrategy;
randomData = new RandomDataGenerator(randomGenerator);
}