Package megamek.common.comparators
Record Class WeaponComparatorNum
java.lang.Object
java.lang.Record
megamek.common.comparators.WeaponComparatorNum
- All Implemented Interfaces:
Comparator<WeaponMounted>
public record WeaponComparatorNum(Entity entity)
extends Record
implements Comparator<WeaponMounted>
Comparator for sorting Weapons (Mounted that have WeaponTypes) by weapon number.
-
Constructor Summary
ConstructorsConstructorDescriptionWeaponComparatorNum
(Entity entity) Creates an instance of aWeaponComparatorNum
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
compare
(WeaponMounted lhs, WeaponMounted rhs) entity()
Returns the value of theentity
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
WeaponComparatorNum
Creates an instance of aWeaponComparatorNum
record class.- Parameters:
entity
- the value for theentity
record component
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<WeaponMounted>
-
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. -
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)
.- Specified by:
equals
in interfaceComparator<WeaponMounted>
- Specified by:
equals
in classRecord
- Parameters:
o
- the object with which to compare- Returns:
true
if this object is the same as theo
argument;false
otherwise.
-
entity
Returns the value of theentity
record component.- Returns:
- the value of the
entity
record component
-