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 aWeaponComparatorNumrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompare(WeaponMounted lhs, WeaponMounted rhs) entity()Returns the value of theentityrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
WeaponComparatorNum
Creates an instance of aWeaponComparatorNumrecord class.- Parameters:
entity- the value for theentityrecord component
-
-
Method Details
-
compare
- Specified by:
comparein 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:
equalsin interfaceComparator<WeaponMounted>- Specified by:
equalsin classRecord- Parameters:
o- the object with which to compare- Returns:
trueif this object is the same as theoargument;falseotherwise.
-
entity
Returns the value of theentityrecord component.- Returns:
- the value of the
entityrecord component
-