Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
vadere
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
110
Issues
110
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
4
Merge Requests
4
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vadere
vadere
Commits
3f189de9
Commit
3f189de9
authored
Nov 02, 2016
by
Jakob Schöttl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make all attributes cloneable
parent
b523ea4c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
4 deletions
+73
-4
VadereState/src/org/vadere/state/attributes/Attributes.java
VadereState/src/org/vadere/state/attributes/Attributes.java
+12
-1
VadereState/tests/org/vadere/state/attributes/TestAttributesCloneable.java
.../org/vadere/state/attributes/TestAttributesCloneable.java
+59
-0
VadereUtils/src/org/vadere/util/geometry/shapes/VPoint.java
VadereUtils/src/org/vadere/util/geometry/shapes/VPoint.java
+1
-1
VadereUtils/src/org/vadere/util/geometry/shapes/VShape.java
VadereUtils/src/org/vadere/util/geometry/shapes/VShape.java
+1
-2
No files found.
VadereState/src/org/vadere/state/attributes/Attributes.java
View file @
3f189de9
...
@@ -16,7 +16,18 @@ package org.vadere.state.attributes;
...
@@ -16,7 +16,18 @@ package org.vadere.state.attributes;
* VPoint,...).
* VPoint,...).
*
*
*/
*/
public
abstract
class
Attributes
extends
DefaultSealable
{
public
abstract
class
Attributes
extends
DefaultSealable
implements
Cloneable
{
/** Used for default ID values of some scenario elements. */
/** Used for default ID values of some scenario elements. */
protected
static
final
int
ID_NOT_SET
=
-
1
;
protected
static
final
int
ID_NOT_SET
=
-
1
;
public
Attributes
()
{}
public
Attributes
cloneAttributes
()
{
try
{
return
(
Attributes
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
throw
new
RuntimeException
(
"This should never happen because the base class Attributes is Cloneable."
);
}
}
}
}
VadereState/tests/org/vadere/state/attributes/TestAttributesCloneable.java
0 → 100644
View file @
3f189de9
package
org.vadere.state.attributes
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
public
class
TestAttributesCloneable
{
private
static
class
SimpleAttributes
extends
Attributes
{
int
id
=
1
;
}
private
static
class
NestedAttributes
extends
Attributes
{
int
id
=
1
;
SimpleAttributes
c
=
new
SimpleAttributes
();
SimpleCloneable
d
=
new
SimpleCloneable
();
}
private
static
class
SimpleCloneable
implements
Cloneable
{
int
id
=
1
;
}
private
static
class
NotCloneableClass
{
@Override
public
Object
clone
()
throws
CloneNotSupportedException
{
return
super
.
clone
();
// throws exception because it does not implement Cloneable
}
}
@Test
public
void
testSimpleCloneable
()
{
try
{
SimpleAttributes
a
=
new
SimpleAttributes
();
SimpleAttributes
b
=
(
SimpleAttributes
)
a
.
cloneAttributes
();
assertEquals
(
a
.
id
,
b
.
id
);
}
catch
(
Exception
e
)
{
fail
(
"clone should not throw exception"
);
}
}
@Test
public
void
testExtendedCloneable
()
{
try
{
NestedAttributes
a
=
new
NestedAttributes
();
NestedAttributes
b
=
(
NestedAttributes
)
a
.
cloneAttributes
();
assertEquals
(
a
.
id
,
b
.
id
);
assertEquals
(
a
.
c
.
id
,
b
.
c
.
id
);
assertEquals
(
a
.
d
.
id
,
b
.
d
.
id
);
}
catch
(
Exception
e
)
{
fail
(
"clone should not throw exception"
);
}
}
@Test
(
expected
=
CloneNotSupportedException
.
class
)
public
void
testNotCloneableClass
()
throws
CloneNotSupportedException
{
new
NotCloneableClass
().
clone
();
}
}
VadereUtils/src/org/vadere/util/geometry/shapes/VPoint.java
View file @
3f189de9
...
@@ -11,7 +11,7 @@ import org.vadere.util.geometry.GeometryUtils;
...
@@ -11,7 +11,7 @@ import org.vadere.util.geometry.GeometryUtils;
*
*
*
*
*/
*/
public
class
VPoint
{
public
class
VPoint
implements
Cloneable
{
public
static
final
VPoint
ZERO
=
new
VPoint
(
0
,
0
);
public
static
final
VPoint
ZERO
=
new
VPoint
(
0
,
0
);
...
...
VadereUtils/src/org/vadere/util/geometry/shapes/VShape.java
View file @
3f189de9
...
@@ -7,9 +7,8 @@ import org.vadere.util.geometry.ShapeType;
...
@@ -7,9 +7,8 @@ import org.vadere.util.geometry.ShapeType;
/**
/**
* Geometric shape and position.
* Geometric shape and position.
*
*
*
*/
*/
public
interface
VShape
extends
Shape
{
public
interface
VShape
extends
Shape
,
Cloneable
{
double
distance
(
VPoint
point
);
double
distance
(
VPoint
point
);
VPoint
closestPoint
(
VPoint
point
);
VPoint
closestPoint
(
VPoint
point
);
...
...
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