类 GenericTypeResolver

java.lang.Object
net.sf.marineapi.util.GenericTypeResolver

public final class GenericTypeResolver extends Object
Utility class for resolving the generic type of a class, mainly for AbstractSentenceListener and AbstractAISMessageListener classes where the generic type needs to be resolved at runtime to filter the incoming messages.
作者:
Kimmo Tuukkanen, Axel Uhl
  • 方法详细资料

    • resolve

      public static Class<?> resolve(Class<?> child, Class<?> parent)
      Attempts to resolve the generic type of given class, with the assumption of single generic type parameter. However, the resolving may not always succeed, often due to more advanced or mixed usage of generics and inheritance. For example, the generic type information may be lost at compile-time because of the Java's type erasure.
      参数:
      child - The class of which parents and generic types to inspect
      parent - The generic class that holds the type being resolved
      返回:
      The generic type of parent
      抛出:
      IllegalStateException - If the generic type cannot be resolved at runtime.