private static @Nullable Object getPrimaryKey(Object implementation, final boolean singleValuedInvocation) {
    final Method method = getPrimaryKeyMethod(implementation.getClass());
    if (method != null) {
      final Object o = DomReflectionUtil.invokeMethod(method, implementation);
      return ReflectionUtil.isAssignable(GenericValue.class, method.getReturnType()) ? ((GenericValue<?>)o).getValue() : o;
    }
    else {
      if (implementation instanceof GenericValue) {
        return singleValuedInvocation? Boolean.TRUE : ((GenericValue<?>)implementation).getValue();
      }
      else {
        return null;
      }
    }
  }
private static @Nullable Object getPrimaryKey(Object implementation, final boolean singleValuedInvocation)