Java tutorial
//package com.java2s; // The MIT License (MIT) import java.awt.Component; import java.util.function.Predicate; public class Main { private static <T> boolean isMatch(Component component, Class<T> type, Predicate<T> predicate) { return type.isInstance(component) && predicate.test(type.cast(component)); } }