Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
84206e99
Commit
84206e99
authored
Nov 17, 2016
by
Jakob Schöttl
Browse files
Change DefaultSealable impl and add comments
parent
2925602b
Changes
1
Hide whitespace changes
Inline
Side-by-side
VadereState/src/org/vadere/state/attributes/DefaultSealable.java
View file @
84206e99
...
...
@@ -2,15 +2,32 @@ package org.vadere.state.attributes;
import
org.apache.commons.attributes.Sealable
;
/**
* Our implementation of {@link Sealable}.
* The {@code sealed} flag shall not be serialized.
*
* @author Jakob Schöttl
*
*/
public
class
DefaultSealable
implements
Sealable
{
/** Should not be serialized. */
private
transient
boolean
sealed
;
/**
* Apache Commons' DefaultSealable throws an exception if the object is already sealed.
*/
@Override
public
void
seal
()
{
if
(
sealed
)
throw
new
IllegalStateException
(
"Object is already sealed."
);
// Attributes currently are sealed right before the simulation starts.
// Throwing an exception when they are already sealed makes a second simulation fail.
// Solutions (other than not throwing a exception) are:
// - Seal as soon as the objects are loaded from JSON.
// - Copy all attributes before starting a simulation.
// This does not make sense, since the attributes are read-only anyway.
// if (sealed)
// throw new IllegalStateException("Object is already sealed.");
sealed
=
true
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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