diff --git a/src-generated/edu/nps/moves/dis7/Domain.java b/src-generated/edu/nps/moves/dis7/Domain.java index f6b959da23e6768fff19985b543eb1382ea6ea65..b44127152923b7ce6369a184d36801232b08a721 100644 --- a/src-generated/edu/nps/moves/dis7/Domain.java +++ b/src-generated/edu/nps/moves/dis7/Domain.java @@ -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 +}