-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#396 Add ReportData class #401
Changes from 3 commits
f3c0754
a65d0a7
626e607
b1fca26
3e30b04
4660d9e
6a6f7ac
b649a57
6839bcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2017-2019 Yegor Bugayenko | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package org.jpeek; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Report data holder. | ||
* | ||
* @since 0.30.9 | ||
*/ | ||
final class ReportData { | ||
/** | ||
* Default mean. | ||
*/ | ||
private static final double DEFAULT_MEAN = 0.5d; | ||
|
||
/** | ||
* Default sigma. | ||
*/ | ||
private static final double DEFAULT_SIGMA = 0.1d; | ||
|
||
/** | ||
* The metric. | ||
*/ | ||
private final String metr; | ||
|
||
/** | ||
* Mean. | ||
*/ | ||
private final double man; | ||
|
||
/** | ||
* Sigma. | ||
*/ | ||
private final double sig; | ||
|
||
/** | ||
* XSL params. | ||
*/ | ||
private final Map<String, Object> args; | ||
|
||
/** | ||
* Ctor. | ||
* @param name Name of the metric | ||
*/ | ||
ReportData(final String name) { | ||
this( | ||
name, new HashMap<>(0), ReportData.DEFAULT_MEAN, ReportData.DEFAULT_SIGMA | ||
); | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* @param name Name of metric | ||
* @param args Params for XSL | ||
*/ | ||
ReportData(final String name, final Map<String, Object> args) { | ||
this( | ||
name, args, ReportData.DEFAULT_MEAN, ReportData.DEFAULT_SIGMA | ||
); | ||
} | ||
|
||
/** | ||
* Ctor. | ||
* @param name Name of the metric | ||
* @param args Params for XSL | ||
* @param mean Mean | ||
* @param sigma Sigma | ||
* @checkstyle ParameterNumberCheck (10 lines) | ||
*/ | ||
ReportData(final String name, final Map<String, Object> args, final double mean, | ||
final double sigma) { | ||
this.metr = name; | ||
this.args = new HashMap<>(args); | ||
this.man = mean; | ||
this.sig = sigma; | ||
} | ||
|
||
/** | ||
* Metric name accessor. | ||
* @return The metric | ||
*/ | ||
public String metric() { | ||
return this.metr; | ||
} | ||
|
||
/** | ||
* Mean accessor. | ||
* @return The mean | ||
*/ | ||
public double mean() { | ||
return this.man; | ||
} | ||
|
||
/** | ||
* Sigma accessor. | ||
* @return Sigma | ||
*/ | ||
public double sigma() { | ||
return this.sig; | ||
} | ||
|
||
/** | ||
* Params accessor. | ||
* @return Params | ||
*/ | ||
public Map<String, Object> params() { | ||
return new HashMap<>(this.args); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HDouss Just returning unmodifiable map would sufficient There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fanifieiev Ok. but I think I should remove the test for immutability or change it to expect Exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @HDouss I would personally not create a test for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fanifieiev it does not harm to have such tests, especially for immutability. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HDouss It is better to use unmodifiable map here