@SuppressWarnings({"rawtypes", "unchecked"})
 public static void assertExists(Class myClass, Class myAnnotation) throws Exception {
   // Checks if an annotation is present
   if (!myClass.isAnnotationPresent(myAnnotation.getClass())) {
     throw new Exception("Annotation : " + myAnnotation.getClass() + " not found.");
   }
 }
Example #2
0
  private void checkDataBinding(Class<? extends AbstractField> class1) {
    boolean ok = false;
    AbstractField b;
    try {
      b = class1.newInstance();
      b.setCaption("Button of type " + class1.getSimpleName());
      try {
        b.setWriteThrough(true);
        b.setReadThrough(true);
        ObjectProperty<String> prop = new ObjectProperty<String>("ABC 123");
        /*
         * This should throw an exception or somehow tell that the
         * property was invalid (wrong type). See #2223.
         */
        b.setPropertyDataSource(prop);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      return;
    }

    if (ok) {
      status.setValue(status.getValue() + " " + class1.getClass().getSimpleName() + "/DB: OK");
    } else {
      status.setValue(status.getValue() + " " + class1.getClass().getSimpleName() + "/DB: FAILED");
    }
  }
  /**
   * Create a Java3D node which does not have a default constructor
   *
   * <p>parameterTypes must contain the classes required by the constructor, use Interger.TYPE,
   * Float.TYPE etc to specifiy primitive types
   *
   * <p>paramters should contain the list of parameters for the constructor, primitive types should
   * be wrapped in the appropriate class (ie Integer, Float )
   */
  protected SceneGraphObject createNode(
      Class j3dClass, Class[] parameterTypes, Object[] parameters) {
    SceneGraphObject ret;
    Constructor constructor;

    try {
      constructor = j3dClass.getConstructor(parameterTypes);
      ret = (SceneGraphObject) constructor.newInstance(parameters);
    } catch (IllegalAccessException e2) {
      throw new SGIORuntimeException(
          "Broken State class for " + j3dClass.getClass().getName() + " - IllegalAccess");
    } catch (InstantiationException e3) {
      throw new SGIORuntimeException("Broken State class for " + j3dClass.getClass().getName());
    } catch (java.lang.reflect.InvocationTargetException e4) {
      throw new SGIORuntimeException(
          "InvocationTargetException for " + j3dClass.getClass().getName());
    } catch (NoSuchMethodException e5) {
      for (int i = 0; i < parameterTypes.length; i++)
        System.err.println(parameterTypes[i].getName());
      System.err.println("------");
      throw new SGIORuntimeException("Invalid constructor for " + j3dClass.getClass().getName());
    }

    return ret;
  }
 /**
  * Creates new entity instance connected with opened database
  *
  * @param <T>
  * @param type The type of the required entity
  * @return New entity instance
  */
 public <T extends ActiveRecordBase> T newEntity(Class<T> type) throws ActiveRecordException {
   T entity = null;
   try {
     entity = type.newInstance();
     entity.setDatabase(m_Database);
   } catch (IllegalAccessException e) {
     throw new ActiveRecordException("Can't instantiate " + type.getClass());
   } catch (InstantiationException e) {
     throw new ActiveRecordException("Can't instantiate " + type.getClass());
   }
   return entity;
 }
Example #5
0
 public void registerEntityType(String suffix, Class<?> entityType) {
   if (entityType.isAssignableFrom(EntityType.class)) {
     entityMapping.put(suffix, entityType);
     if (appName != null) {
       appEntityCache.put(
           entityType,
           CacheManager.getInstance()
               .getCache(appName + "_" + suffix, String.class, entityType.getClass()));
     }
     sysEntityCache.put(
         entityType,
         CacheManager.getInstance().getCache(suffix, String.class, entityType.getClass()));
   }
   throw new IllegalArgumentException("Entity class must extend from EntityType.class");
 }
 /**
  * Method that tries to create specialized type given base type, and a sub-class thereof (which is
  * assumed to use same parametrization as supertype). Similar to calling {@link
  * JavaType#narrowBy(Class)}, but can change underlying {@link JavaType} (from simple to Map, for
  * example), unliked <code>narrowBy</code> which assumes same logical type.
  */
 public static JavaType specialize(JavaType baseType, Class<?> subclass) {
   // Currently only SimpleType instances can become something else
   if (baseType instanceof SimpleType) {
     // and only if subclass is an array, Collection or Map
     if (subclass.isArray()
         || Map.class.isAssignableFrom(subclass)
         || Collection.class.isAssignableFrom(subclass)) {
       // need to assert type compatibility...
       if (!baseType.getRawClass().isAssignableFrom(subclass)) {
         throw new IllegalArgumentException(
             "Class " + subclass.getClass().getName() + " not subtype of " + baseType);
       }
       // this _should_ work, right?
       JavaType subtype = instance._fromClass(subclass, new TypeBindings(baseType.getRawClass()));
       // one more thing: handlers to copy?
       Object h = baseType.getValueHandler();
       if (h != null) {
         subtype.setValueHandler(h);
       }
       h = baseType.getTypeHandler();
       if (h != null) {
         subtype = subtype.withTypeHandler(h);
       }
       return subtype;
     }
   }
   // otherwise regular narrowing should work just fine
   return baseType.narrowBy(subclass);
 }
Example #7
0
  public final Set<Action> listActions() {
    Set<Action> result = new HashSet<Action>();

    /*
     * Search on this entity, climbing up the class hierarchy.
     */
    Class<?> self = this.getClass();
    while (!Object.class.equals(self)) {
      for (Method m : self.getClass().getDeclaredMethods()) {
        if (m.isAnnotationPresent(Action.class)) {
          result.add(m.getAnnotation(Action.class));
        } // if
      } // for
      self = self.getSuperclass();
    } // while

    /*
     * Search on all mixins.
     */
    for (Object o : this.getMixins()) {
      for (Method m : o.getClass().getDeclaredMethods()) {
        if (m.isAnnotationPresent(Action.class)) {
          result.add(m.getAnnotation(Action.class));
        } // if
      } // for
    } // for

    return result;
  }
Example #8
0
 /**
  * Parse the @TreeView annotation.
  *
  * @param nodeClass Object to be parsed.
  * @throws Exception
  */
 @SuppressWarnings("rawtypes")
 protected void parseTreeView(Tree path, Class nodeClass, Class parentClass, String collectionName)
     throws Exception {
   this.treeAnnotation = path;
   this.nodeClass = nodeClass;
   this.parentClass = parentClass;
   this.collectionName = collectionName;
   if (treeAnnotation == null) {
     treeAnnotation =
         this.getClass().getDeclaredField("defaultPathAnnotation").getAnnotation(Tree.class);
   }
   if (Is.empty(treeAnnotation.pathProperty())) {
     throw new XavaException("error.collectionDoesNotRepresentATreeView");
   }
   this.pathProperty = treeAnnotation.pathProperty();
   this.idSeparator = treeAnnotation.idSeparator();
   parseNodeProperty();
   this.orderProperty = null;
   this.initialExpandedState = treeAnnotation.initialExpandedState();
   this.keyIncrement = treeAnnotation.orderIncrement();
   if (this.keyIncrement < 2) {
     this.keyIncrement = 2;
   }
   setPathSeparator(treeAnnotation.pathSeparator());
   if (nodeClass.getClass().isAnnotationPresent(Id.class)) {
     entityObject = true;
   } else {
     entityObject = false;
   }
   parseOrderDefined();
   parseEntityObject();
 }
  /**
   * Create a new Java3D node from the supplied class using the parameterless constructor
   *
   * <p>For Java3D nodes which do not have a default constructor you must overload this method and
   * create the object using createNode( className, parameters ) This will correctly handle
   * subclasses of Java3D classes
   */
  protected SceneGraphObject createNode(Class state) {
    SceneGraphObject ret;

    try {
      ret = (SceneGraphObject) state.newInstance();

      // System.err.println("Created J3D node for "+className );
    } catch (IllegalAccessException exce) {
      throw new SGIORuntimeException(
          "Broken State class for " + state.getClass().getName() + " - IllegalAccess");
    } catch (InstantiationException excep) {
      throw new SGIORuntimeException("Broken State class for " + state.getClass().getName());
    }

    return ret;
  }
  /**
   * Register an event. python-facing. this version converts from string info.
   *
   * @param handler function handler
   * @param type Event type string
   * @param priority Event priority string
   */
  public void registerEvent(PyObject handler, PyString type, PyString priority) {
    try {
      String clazz = type.asString();
      Class<?> event = null;

      if (clazz.contains(".")) {
        try {
          // try if we can find the class
          event = Class.forName(clazz);
        } catch (ClassNotFoundException e) {
          // assume the subpackage and class name was given and append org.bukkit.event
          event = Class.forName("org.bukkit.event." + clazz);
        }
      } else if (customEvents.containsKey(clazz)) {
        // check if the name of a custom event was given
        event = customEvents.get(clazz);
      } else {
        throw new IllegalArgumentException("Could not find Event " + clazz);
      }

      if (!event.getClass().isInstance(event)) {
        throw new IllegalArgumentException(type.asString().toUpperCase() + " is not of type Event");
      }
      Class<? extends Event> realtype = (Class<? extends Event>) event;
      EventPriority realpriority = EventPriority.valueOf(priority.upper());
      registerEvent(handler, realtype, realpriority);

    } catch (ClassNotFoundException e) {
      Bukkit.getLogger()
          .log(
              Level.SEVERE,
              "Could not register event " + type + " because the event could not be found",
              e);
    }
  }
Example #11
0
  /**
   * TODO: not yet commented.
   *
   * @return
   */
  public Set<Attribute> getAttributes() {
    Set<Attribute> result = new HashSet<Attribute>();

    /*
     * Search on this entity, climbing up the class hierarchy.
     */
    Class<?> self = this.getClass();
    while (!Object.class.equals(self)) {
      for (Field f : self.getClass().getDeclaredFields()) {
        if (f.isAnnotationPresent(Attribute.class)) {
          result.add(f.getAnnotation(Attribute.class));
        } // if
      } // for
      self = self.getSuperclass();
    } // while

    /*
     * Search on all mixins.
     */
    for (Object o : this.getMixins()) {
      for (Field f : o.getClass().getDeclaredFields()) {
        if (f.isAnnotationPresent(Attribute.class)) {
          result.add(f.getAnnotation(Attribute.class));
        } // if
      } // for
    } // for

    return result;
  }
  @Test
  public void testgeneric4() throws SecurityException, NoSuchMethodException {
    System.out.println("====  testgeneric4 ====");

    Type type = GenericUtils.newArrayType(String.class);
    System.out.println(type.getClass().getName());
    System.out.println("isRawArray:" + GenericUtils.isRawArray(type));
    System.out.println("rawType:" + GenericUtils.getRawClass(type));

    Class<?> c = new String[0].getClass();
    System.out.println(c.getClass().getName());
    System.out.println(c.getName());
    System.out.println(c);

    System.out.println(type.equals(c));
    System.out.println("====  testgeneric4b ====");
    FieldEx field = BeanUtils.getField(GenericTypeTemplateTest.class, "field1");
    System.out.println(field.getType().equals(c));
    System.out.println(field.getGenericType().equals(c)); // 当不是泛型时,返回的是class对象
    System.out.println(field.getType());
    System.out.println(field.getGenericType());
    System.out.println(type);
    System.out.println(field.getGenericType().equals(type));

    System.out.println("====  testgeneric4c ====");
    field = BeanUtils.getField(GenericTypeTemplateTest.class, "field2");
    System.out.println(field.getType());
    System.out.println(field.getGenericType());
    type = field.getGenericType();
    System.out.println("isRawArray:" + GenericUtils.isRawArray(type));
    System.out.println("rawType:" + GenericUtils.getRawClass(type));
    System.out.println(GenericUtils.getRawClass(type).equals(field.getType()));
  }
  private void setValueUsingSetter(Object value) throws ComponentConfigurationException {
    if (setterParamType == null || setter == null) {
      throw new ComponentConfigurationException("No setter found");
    }

    String exceptionInfo =
        object.getClass().getName()
            + "."
            + setter.getName()
            + "( "
            + setterParamType.getClass().getName()
            + " )";

    if (listener != null) {
      listener.notifyFieldChangeUsingSetter(fieldName, value, object);
    }

    try {
      setter.invoke(object, new Object[] {value});
    } catch (IllegalAccessException e) {
      throw new ComponentConfigurationException("Cannot access method: " + exceptionInfo, e);
    } catch (IllegalArgumentException e) {
      throw new ComponentConfigurationException(
          "Invalid parameter supplied while setting '" + value + "' to " + exceptionInfo, e);
    } catch (InvocationTargetException e) {
      throw new ComponentConfigurationException(
          "Setter "
              + exceptionInfo
              + " threw exception when called with parameter '"
              + value
              + "': "
              + e.getTargetException().getMessage(),
          e);
    }
  }
Example #14
0
  public static Object checkTypeAndNotNull(String field, Map data, Class expect)
      throws GeneralException {

    Object o = data.get(field);

    if (o == null) {

      throw new GeneralException("Expected a value for: " + field);
    }

    if (expect != null) {

      if (!expect.isAssignableFrom(o.getClass())) {

        throw new GeneralException(
            "Expected type for: "
                + field
                + " to be: "
                + expect.getClass().getName()
                + ", is: "
                + o.getClass().getName());
      }
    }

    return o;
  }
Example #15
0
  private void checkButton(Class<? extends Button> class1) {
    boolean ok = false;
    AbstractComponent b;
    try {
      b = class1.newInstance();
      b.setCaption("Button of type " + class1.getSimpleName());
      ok = true;
    } catch (Exception e1) {
      e1.printStackTrace();
    }

    if (ok) {
      status.setValue(status.getValue() + " " + class1.getClass().getSimpleName() + ": OK");
    } else {
      status.setValue(status.getValue() + " " + class1.getClass().getSimpleName() + ": FAILED");
    }
  }
Example #16
0
 private void guessClassReference(TypedValues list, String name) {
   try {
     Class<?> type = Class.forName(fixPotentialArrayName(name));
     list.add(new TypedValue(type.getClass(), type));
   } catch (ClassNotFoundException y) {
     _logger.fine(name + " looked like a class reference but is not");
   }
 }
  private Class<?> getUnwrappedClass(Class<? extends Object> class1) {
    Class<?> result = class1;

    while (null != result && result.getClass().getSimpleName().contains("$$EnhancerBy"))
      result = result.getSuperclass();

    return result;
  }
Example #18
0
 /**
  * get tag that has specified id attribute. You don't need to cast() because you can specify the
  * tag type.
  *
  * <pre>
  * // sample: get a Div tag having id=&quot;foo&quot; attribute.
  * html.getById(&quot;foo&quot;, Div.class);
  * </pre>
  *
  * @param id
  * @param tagType
  * @return
  * @throws TagTypeUnmatchException
  */
 @SuppressWarnings("unchecked")
 public <T extends AbstractJaxb> T getById(String id, Class<T> tagType)
     throws TagTypeUnmatchException {
   Object obj = GetByIdUtil.getById(id, this);
   if (obj != null && !obj.getClass().isAssignableFrom(tagType)) {
     throw new TagTypeUnmatchException(tagType.getClass(), obj.getClass());
   }
   return (T) obj;
 }
Example #19
0
 public Bundle getCustomEventExtrasBundle(Class class1) {
   Bundle bundle =
       ml.getBundle("com.google.android.gms.ads.mediation.customevent.CustomEventAdapter");
   if (bundle != null) {
     return bundle.getBundle(class1.getClass().getName());
   } else {
     return null;
   }
 }
Example #20
0
  /**
   * Make glue object implementing interface cl that will call the supplied JS function when called.
   * Only interfaces were all methods have the same signature is supported.
   *
   * @return The glue object or null if <tt>cl</tt> is not interface or has methods with different
   *     signatures.
   */
  static Object create(Context cx, Class<?> cl, Callable function) {
    if (!cl.isInterface()) throw new IllegalArgumentException();

    Scriptable topScope = ScriptRuntime.getTopCallScope(cx);
    ClassCache cache = ClassCache.get(topScope);
    InterfaceAdapter adapter;
    adapter = (InterfaceAdapter) cache.getInterfaceAdapter(cl);
    ContextFactory cf = cx.getFactory();
    if (adapter == null) {
      Method[] methods = cl.getMethods();
      if (methods.length == 0) {
        throw Context.reportRuntimeError2(
            "msg.no.empty.interface.conversion", String.valueOf(function), cl.getClass().getName());
      }
      boolean canCallFunction = false;
      canCallFunctionChecks:
      {
        Class<?>[] argTypes = methods[0].getParameterTypes();
        // check that the rest of methods has the same signature
        for (int i = 1; i != methods.length; ++i) {
          Class<?>[] types2 = methods[i].getParameterTypes();
          if (types2.length != argTypes.length) {
            break canCallFunctionChecks;
          }
          for (int j = 0; j != argTypes.length; ++j) {
            if (types2[j] != argTypes[j]) {
              break canCallFunctionChecks;
            }
          }
        }
        canCallFunction = true;
      }
      if (!canCallFunction) {
        throw Context.reportRuntimeError2(
            "msg.no.function.interface.conversion",
            String.valueOf(function),
            cl.getClass().getName());
      }
      adapter = new InterfaceAdapter(cf, cl);
      cache.cacheInterfaceAdapter(cl, adapter);
    }
    return VMBridge.instance.newInterfaceProxy(
        adapter.proxyHelper, cf, adapter, function, topScope);
  }
Example #21
0
  public static void main(String[] args)
      throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
          InvocationTargetException, NoSuchFieldException {
    Reflection obj = new Reflection();
    Class<Reflection> c = Reflection.class;

    // test the ability to reflectively get constants, which are usually baked
    // in to bytecodes by the compiler
    Field f = c.getField("constValue");
    System.out.println(f.get(null));
    Field f2 = c.getField("constInt");
    System.out.println(f2.get(null));
    Field f3 = c.getField("constFloat");
    System.out.println(f3.get(null));
    Field f4 = c.getField("constDouble");
    System.out.println(f4.get(null));
    Field f5 = c.getField("constLong");
    System.out.println(f5.get(null));
    Field f6 = c.getField("constShort");
    System.out.println(f6.get(null));
    Field f7 = c.getField("constBool");
    System.out.println(f7.get(null));

    Method bytecodeMethod = c.getClass().getMethod("toString");
    Method nativeMethod = c.getClass().getMethod("isArray");
    Method nativeMethodWithArgs = c.getClass().getMethod("isInstance", Object.class);
    Method unboxingMethod = c.getMethod("add", long.class, long.class);
    Method boxingMethod = c.getMethod("add", Long.class, Long.class);
    Method voidMethod = c.getMethod("foo");
    // regular method reflected invocation
    System.out.println("toString: " + bytecodeMethod.invoke(c));
    // native method reflected invocation
    System.out.println("is array? " + nativeMethod.invoke(c));
    // native method reflected invocation with parameters
    System.out.println("is instance? " + nativeMethodWithArgs.invoke(c, obj));
    // unboxing has to be handled specially by our native method invoker
    Long a = new Long(40L);
    Long b = new Long(2L);
    System.out.println("unboxing: " + unboxingMethod.invoke(null, a, b));
    // boxing is handled by javac
    System.out.println("boxing: " + boxingMethod.invoke(null, 1300L, 37L));
    // void return values
    System.out.println("void return: " + voidMethod.invoke(null));
  }
Example #22
0
 private void checkJavaVersion() {
   try {
     // ## Java 1.4 begin ##
     // check for existence of this class (avoiding Class . forName)
     Class<?> clazz = java.sql.Savepoint.class;
     clazz.getClass();
     // ## Java 1.4 end ##
   } catch (NoClassDefFoundError e) {
     throw DbException.get(ErrorCode.UNSUPPORTED_JAVA_VERSION);
   }
 }
Example #23
0
 public static <T> String genTable(List<T> list, Class<? extends T> t) {
   StringBuilder buffer = new StringBuilder();
   try {
     HeaderTemplate headerTemplate = t.getClass().getAnnotation(HeaderTemplate.class);
     if (headerTemplate != null) {
       buffer.append(headerTemplate.value());
     }
     for (int i = 0; i < list.size(); i++) {
       buffer.append(genItem(list.get(i)));
     }
     FooterTemplate footerTemplate = t.getClass().getAnnotation(FooterTemplate.class);
     if (footerTemplate != null) {
       buffer.append(footerTemplate.value());
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return buffer.toString();
 }
  public void testMethodPatternUsingMethodAnnotations() throws Exception {
    Class<?> foo = Foo.class.getClass();
    ParameterInfo info = new ParameterInfo(1, foo.getClass(), foo.getAnnotations(), null);

    assertNotNull(info);
    assertNotNull(info.toString());

    assertEquals(1, info.getIndex());
    assertEquals(foo, info.getType());
    assertNull(info.getExpression());
    assertNotNull(info.getAnnotations());
  }
Example #25
0
  private void checkCheckBox(Class<? extends CheckBox> class1) {
    boolean ok = false;
    CheckBox b;
    try {
      b = class1.newInstance();
    } catch (Exception e1) {
      e1.printStackTrace();
      return;
    }

    b.setCaption("Button of type " + class1.getSimpleName());
    status.setValue(status.getValue() + " " + class1.getClass().getSimpleName() + ": OK");
  }
  public IllegalStateException error(final String format, final Object... args) {
    final String message = String.format(format, args);

    if (error == DocoptLanguageError.class) {
      throw new DocoptLanguageError(message);
    }

    if (error == DocoptExitException.class) {
      throw new DocoptExitException(1, message, true);
    }

    return new IllegalStateException("Unexpected exception: " + error.getClass().getName());
  }
Example #27
0
 // Filter
 @SuppressWarnings("unchecked")
 private <T extends DB2AuthBase> Collection<T> getAuths(
     DBRProgressMonitor monitor, Class<T> authClass) throws DBException {
   Collection<T> listAuths = (Collection<T>) cachePerObject.get(authClass.getClass());
   if (listAuths == null) {
     listAuths = new ArrayList<>();
     for (DB2AuthBase db2Auth : authCache.getAllObjects(monitor, this)) {
       if (authClass.isInstance(db2Auth)) {
         listAuths.add((T) db2Auth);
       }
     }
   }
   return listAuths;
 }
Example #28
0
  public static <T> String genTable(long offset, long size, List<T> list, Class<? extends T> t) {
    StringBuilder buffer = new StringBuilder();
    try {
      HeaderTemplate headerTemplate = t.getClass().getAnnotation(HeaderTemplate.class);
      if (headerTemplate != null) {
        buffer.append(headerTemplate.value());
      }
      if (list.size() > size) {
        // 说明要分页了,list里面就是全部数据
        // 下面需要验证一下offset+size是否大于list.size()
        if ((offset + size) > list.size()) {
          // 说明size大了,到了最后一页,那么应该以list.size()为最后一个
          for (int i = (int) offset; i < list.size(); i++) {
            buffer.append(genItem(list.get(i)));
          }
        } else {
          for (int i = (int) offset; i < (offset + size); i++) {
            buffer.append(genItem(list.get(i)));
          }
        }

      } else {
        for (int i = 0; i < list.size(); i++) {
          buffer.append(genItem(list.get(i)));
        }
      }
      FooterTemplate footerTemplate = t.getClass().getAnnotation(FooterTemplate.class);
      if (footerTemplate != null) {
        buffer.append(footerTemplate.value());
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return buffer.toString();
  }
    /**
     * Checks in the {@link AtmosphereConfig} if the {@link #propertyName} is defined as an
     * init-param and instantiate the appropriate class.
     *
     * <p>If instantiation fails, the exception is logged and {@code null} is returned.
     *
     * @param desiredType the type to be returned
     * @param config the configuration that provides parameters
     * @param <T> the generic for modular call
     * @return the instance of the expected class, {@code null} if an error occurs
     */
    public <T> T retrieve(final Class<T> desiredType, final AtmosphereConfig config) {
      final String initParameter = config.getInitParameter(this.propertyName);
      final String className = (initParameter != null) ? initParameter : defaultClass;

      try {
        final AtmosphereFramework fwk = config.framework();
        final Object retval =
            fwk.newClassInstance(
                desiredType, desiredType.getClass().cast(Class.forName(className)));
        return desiredType.cast(retval);
      } catch (Exception e) {
        logger.error("Unable to initialize {}", getClass().getName(), e);
        return null;
      }
    }
Example #30
0
 /**
  * 根据id获取对象列表
  *
  * @param ids
  * @return
  */
 @SuppressWarnings("unchecked")
 public List<T> get(final Class<T> entityClass, final Collection<PK> ids) {
   Search search = new Search(entityClass);
   search.setResultMode(Search.RESULT_LIST);
   JPAAnnotationMetadataUtil metadataUtil = new JPAAnnotationMetadataUtil();
   T entity;
   try {
     entity = entityClass.newInstance();
   } catch (Exception e) {
     logger.error("根据主键集合查找对象 {}发生异常! ", entityClass.getClass());
     throw new RuntimeException("根据主键集合查找对象发生异常", e);
   }
   String propertyName = metadataUtil.getIdPropertyName(entity);
   SearchUtil.addFilterIn(search, propertyName, ids);
   return searchProcessor.search(this.getEntityManager().getPersistEntityManager(), search);
 }