forked from SeaseLtd/rated-ranking-evaluator
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SeaseLtd#109: Javadoc, tidying, reducing code repetition.
- Loading branch information
Matt Pearce
committed
Mar 16, 2020
1 parent
0784fdc
commit 3a0d2c6
Showing
12 changed files
with
121 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
rre-core/src/main/java/io/sease/rre/core/domain/metrics/MetricClassConfigurationManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.sease.rre.core.domain.metrics; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** | ||
* Singleton utility class for instantiating the metric class manager, | ||
* and managing metric configuration details. | ||
* | ||
* @author Matt Pearce (mpearce@opensourceconnections.com) | ||
*/ | ||
public class MetricClassConfigurationManager { | ||
|
||
private static MetricClassConfigurationManager instance; | ||
|
||
private BigDecimal defaultMaximumGrade = BigDecimal.valueOf(3); | ||
private BigDecimal defaultMissingGrade = BigDecimal.valueOf(2); | ||
|
||
private MetricClassConfigurationManager() { | ||
// Private constructor | ||
} | ||
|
||
public static MetricClassConfigurationManager getInstance() { | ||
if (instance == null) { | ||
instance = new MetricClassConfigurationManager(); | ||
} | ||
return instance; | ||
} | ||
|
||
/** | ||
* Build the appropriate {@link MetricClassManager} for the metric | ||
* configuration passed. | ||
* @param metrics the simple metric configurations - a list of metric classes. | ||
* @param parameterizedMetrics the parameterized metric configuration, consisting | ||
* of class names and additional configuration. | ||
* @return a {@link MetricClassManager} that can instantiate all of the | ||
* configured metrics. | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public MetricClassManager buildMetricClassManager(final Collection<String> metrics, final Map<String, Map> parameterizedMetrics) { | ||
final MetricClassManager metricClassManager; | ||
if (parameterizedMetrics == null || parameterizedMetrics.isEmpty()) { | ||
metricClassManager = new SimpleMetricClassManager(metrics); | ||
} else { | ||
metricClassManager = new ParameterizedMetricClassManager(metrics, parameterizedMetrics); | ||
} | ||
return metricClassManager; | ||
} | ||
|
||
/** | ||
* @return the default maximum grade to use when evaluating metrics. May be | ||
* overridden in parameterized metric configuration. | ||
*/ | ||
public BigDecimal getDefaultMaximumGrade() { | ||
return defaultMaximumGrade; | ||
} | ||
|
||
/** | ||
* Set the default maximum grade to use when evaluating metrics. | ||
* @param defaultMaximumGrade the grade to use. | ||
* @return the singleton manager instance. | ||
*/ | ||
public MetricClassConfigurationManager setDefaultMaximumGrade(final float defaultMaximumGrade) { | ||
this.defaultMaximumGrade = BigDecimal.valueOf(defaultMaximumGrade); | ||
return this; | ||
} | ||
|
||
/** | ||
* @return the default grade to use when evaluating metrics, and no judgement | ||
* is present for the current document. May be overridden in parameterized | ||
* metric configuration. | ||
*/ | ||
public BigDecimal getDefaultMissingGrade() { | ||
return defaultMissingGrade; | ||
} | ||
|
||
/** | ||
* Set the default missing judgement grade to use when evaluating metrics. | ||
* @param defaultMissingGrade the grade to use. | ||
* @return the singleton manager instance. | ||
*/ | ||
public MetricClassConfigurationManager setDefaultMissingGrade(final float defaultMissingGrade) { | ||
this.defaultMissingGrade = BigDecimal.valueOf(defaultMissingGrade); | ||
return this; | ||
} | ||
} |
58 changes: 0 additions & 58 deletions
58
rre-core/src/main/java/io/sease/rre/core/domain/metrics/MetricClassManagerFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters