Record Class WPClassMapping<K,V>

java.lang.Object
java.lang.Record
net.ygbstudio.powerwp4j.models.entities.WPClassMapping<K,V>
Type Parameters:
K - The type of the key.
V - The type of the taxonomy value.
Record Components:
key - The key of the class (category or tag).
value - The value of the taxonomy marker.

public record WPClassMapping<K,V>(K key, V value) extends Record
Represents a mapping between a WordPress API class ID and a taxonomy value.
  • Constructor Details

    • WPClassMapping

      public WPClassMapping(@NotNull K key, @NotNull V value)
      Creates an instance of a WPClassMapping record class.
      Parameters:
      key - the value for the key record component
      value - the value for the value record component
  • Method Details

    • toNumberSet

      public static <T, U extends Number> Set<U> toNumberSet(@NotNull @NotNull Set<WPClassMapping<T,U>> classMappingSet)
      Converts a set of WPClassMapping with numeric values to a set of the same numeric type.
      Type Parameters:
      T - the type of the key in each class mapping object
      U - the numeric type of the values in the input set and the output set
      Parameters:
      classMappingSet - the set of WPClassMapping objects to convert
      Returns:
      a set of the numeric type U
    • toNumberList

      @NotNull public static <T, U extends Number> @Unmodifiable @NotNull List<U> toNumberList(@NotNull @NotNull List<WPClassMapping<T,U>> classMappingList)
      Converts a list of WPClassMapping with numeric values to a set of the same numeric type.
      Type Parameters:
      T - the type of the key in each class mapping object
      U - the numeric type of the values in the input list and the output set
      Parameters:
      classMappingList - the list of WPClassMapping objects to convert
      Returns:
      a list of the numeric type U
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      @NotNull public K key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • value

      @NotNull public V value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component