Package megamek.common.units
Record Class UnitTargetPair
java.lang.Object
java.lang.Record
megamek.common.units.UnitTargetPair
This class is a record of pair of a (InGameObject) unit and a (Targetable) target. Note that two such pairs are equal
when their contents count as equal which is when the IDs of unit and target are equal. This object itself is
immutable although the underlying objects are not.
-
Constructor Summary
ConstructorsConstructorDescriptionUnitTargetPair(InGameObject unit, Targetable target) Creates an instance of aUnitTargetPairrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.unit()Returns the value of theunitrecord component.
-
Constructor Details
-
UnitTargetPair
Creates an instance of aUnitTargetPairrecord class.- Parameters:
unit- the value for theunitrecord componenttarget- the value for thetargetrecord component
-
-
Method Details
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
unit
Returns the value of theunitrecord component.- Returns:
- the value of the
unitrecord component
-
target
Returns the value of thetargetrecord component.- Returns:
- the value of the
targetrecord component
-