Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
d1e72b85
Commit
d1e72b85
authored
5 years ago
by
J. M. Bailey
Browse files
Options
Downloads
Patches
Plain Diff
Fix equals method
parent
30acbbbe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src-generated/edu/nps/moves/dis7/Domain.java
+46
-16
46 additions, 16 deletions
src-generated/edu/nps/moves/dis7/Domain.java
with
46 additions
and
16 deletions
src-generated/edu/nps/moves/dis7/Domain.java
+
46
−
16
View file @
d1e72b85
...
...
@@ -2,7 +2,6 @@
* Copyright (c) 2008-2019, MOVES Institute, Naval Postgraduate School. All rights reserved.
* This work is licensed under the BSD open source license, available at https://www.movesinstitute.org/licenses/bsd.html
*/
package
edu.nps.moves.dis7
;
import
java.io.DataInputStream
;
...
...
@@ -14,9 +13,10 @@ import java.lang.reflect.InvocationTargetException;
import
edu.nps.moves.dis7.enumerations.*
;
/**
* An example approximating a Java enum "superclass".
Can't use an interface, because we need the two
* An example approximating a Java enum "superclass". Can't use an interface, because we need the two
* static methods, which can't go into an interface
*/
//@formatter:off
public
class
Domain
{
private
Domain
()
{
}
...
...
@@ -30,10 +30,8 @@ public class Domain
private
Method
unmarshalDis
;
private
Method
getValue
;
private
Method
getDescription
;
//@formatter:off
//@formatter:off
public
static
Domain
inst
(
PlatformDomain
d
)
{
return
_inst
(
d
);
}
// uid 8
public
static
Domain
inst
(
MunitionDomain
d
)
{
return
_inst
(
d
);
}
// uid 14
...
...
@@ -41,7 +39,6 @@ public class Domain
public
static
Domain
inst
(
SupplyDomain
d
)
{
return
_inst
(
d
);
}
// uid 600
//@formatter:on
private
static
Domain
_inst
(
Object
o
)
{
Domain
d
=
new
Domain
();
...
...
@@ -49,24 +46,26 @@ public class Domain
d
.
init
();
return
d
;
}
private
void
init
()
{
Class
c
=
enumInst
.
getClass
();
try
{
//@formatter:off
marshalBuff
=
c
.
getDeclaredMethod
(
"marshal"
,
new
Class
[]{
ByteBuffer
.
class
});
marshalDos
=
c
.
getDeclaredMethod
(
"marshal"
,
new
Class
[]{
DataOutputStream
.
class
});
unmarshalBuff
=
c
.
getDeclaredMethod
(
"unmarshalEnum"
,
new
Class
[]{
ByteBuffer
.
class
});
unmarshalDis
=
c
.
getDeclaredMethod
(
"unmarshalEnum"
,
new
Class
[]{
DataInputStream
.
class
});
mSize
=
c
.
getDeclaredMethod
(
"getMarshalledSize"
,
(
Class
[])
null
);
getValue
=
c
.
getDeclaredMethod
(
"getValue"
,
(
Class
[])
null
);
getDescription
=
c
.
getDeclaredMethod
(
"getDescription"
,
(
Class
[])
null
);
marshalBuff
=
c
.
getDeclaredMethod
(
"marshal"
,
new
Class
[]{
ByteBuffer
.
class
});
marshalDos
=
c
.
getDeclaredMethod
(
"marshal"
,
new
Class
[]{
DataOutputStream
.
class
});
unmarshalBuff
=
c
.
getDeclaredMethod
(
"unmarshalEnum"
,
new
Class
[]{
ByteBuffer
.
class
});
unmarshalDis
=
c
.
getDeclaredMethod
(
"unmarshalEnum"
,
new
Class
[]{
DataInputStream
.
class
});
mSize
=
c
.
getDeclaredMethod
(
"getMarshalledSize"
,
(
Class
[])
null
);
getValue
=
c
.
getDeclaredMethod
(
"getValue"
,
(
Class
[])
null
);
getDescription
=
c
.
getDeclaredMethod
(
"getDescription"
,
(
Class
[])
null
);
//@formatter:on
}
catch
(
NoSuchMethodException
ex
)
{
System
.
err
.
println
(
"Can't find methods in "
+
c
.
getSimpleName
());
}
System
.
err
.
println
(
"Can't find methods in "
+
c
.
getSimpleName
());
}
}
public
int
getValue
()
{
return
(
Integer
)
invoke
(
getValue
,
(
Object
[])
null
);
...
...
@@ -123,5 +122,36 @@ public class Domain
{
return
getDescription
();
}
}
/*
* Override of default equals method. Calls equalsImpl() for content comparison.
*/
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
return
equalsImpl
(
obj
);
}
/**
* Compare all fields that contribute to the state, ignoring
* transient and static fields, for <code>this</code> and the supplied object
*
* @param obj the object to compare to
* @return true if the objects are equal, false otherwise.
*/
public
boolean
equalsImpl
(
Object
obj
)
{
final
Domain
rhs
=
(
Domain
)
obj
;
return
enumInst
.
equals
(
rhs
.
enumInst
);
}
//@formatter:on
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment