Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ecomod
zmt-jscience
Commits
17e2a4cc
Commit
17e2a4cc
authored
Jan 13, 2016
by
mey
Browse files
ValuableAmountAdapter.java: added factory method wrap to better handle null
made constructor private updated ConfigurableStorage
parent
383263a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/zmt/storage/ConfigurableStorage.java
View file @
17e2a4cc
...
...
@@ -204,15 +204,15 @@ public class ConfigurableStorage<Q extends Quantity> extends BaseStorage<Q> impl
public
class
MyPropertiesProxy
{
public
Valuable
getAmount
()
{
return
new
ValuableAmountAdapter
(
ConfigurableStorage
.
this
.
getAmount
());
return
ValuableAmountAdapter
.
wrap
(
ConfigurableStorage
.
this
.
getAmount
());
}
public
Valuable
getLowerLimit
()
{
return
new
ValuableAmountAdapter
(
ConfigurableStorage
.
this
.
getLowerLimit
());
return
ValuableAmountAdapter
.
wrap
(
ConfigurableStorage
.
this
.
getLowerLimit
());
}
public
Valuable
getUpperLimit
()
{
return
new
ValuableAmountAdapter
(
ConfigurableStorage
.
this
.
getUpperLimit
());
return
ValuableAmountAdapter
.
wrap
(
ConfigurableStorage
.
this
.
getUpperLimit
());
}
public
double
getFactorIn
()
{
...
...
src/main/java/de/zmt/util/ValuableAmountAdapter.java
View file @
17e2a4cc
...
...
@@ -13,7 +13,7 @@ import sim.util.Valuable;
public
class
ValuableAmountAdapter
implements
Valuable
{
private
final
Amount
<?>
amount
;
p
ublic
ValuableAmountAdapter
(
Amount
<?>
amount
)
{
p
rivate
ValuableAmountAdapter
(
Amount
<?>
amount
)
{
super
();
this
.
amount
=
amount
;
}
...
...
@@ -27,4 +27,18 @@ public class ValuableAmountAdapter implements Valuable {
public
String
toString
()
{
return
amount
.
toString
();
}
/**
* Returns {@code amount} wrapped into a {@link ValuableAmountAdapter} or
* <code>null</code> if {@code amount} is null.
*
* @param amount
* @return wrapped {@code amount}
*/
public
static
ValuableAmountAdapter
wrap
(
Amount
<?>
amount
)
{
if
(
amount
!=
null
)
{
return
new
ValuableAmountAdapter
(
amount
);
}
return
null
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment