Skip to content

Commit

Permalink
#180 improve comparison in Triple
Browse files Browse the repository at this point in the history
  • Loading branch information
openwms committed Sep 26, 2024
1 parent 5143c53 commit c154b6c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.openwms.core.lang;

import java.util.Objects;

/**
* A Triple.
*
Expand All @@ -32,7 +34,7 @@ public record Triple<K, V, T>(K key, V value, T type) {
*/
@SuppressWarnings("unchecked")
public <U> U valueAs(Class<U> clazz) {
if (clazz.equals(this.type.getClass())) {
if (Objects.equals(this.type.getClass().getComponentType(), clazz.getComponentType())) {
return (U) value;
}
throw new ClassCastException("Cannot case requested type [%s] from [%s]".formatted(clazz, type.getClass()));
Expand Down

0 comments on commit c154b6c

Please sign in to comment.