org.eclipse.persistence.internal.helper.Helper.areTypesAssignable()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.eclipse.persistence.internal.helper.Helper.areTypesAssignable()方法的一些代码示例,展示了Helper.areTypesAssignable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Helper.areTypesAssignable()方法的具体详情如下:
包路径:org.eclipse.persistence.internal.helper.Helper
类名称:Helper
方法名:areTypesAssignable

Helper.areTypesAssignable介绍

[英]PUBLIC: Compare two vectors of types. Return true if the size of the vectors is the same and each of the types in the first Vector are assignable from the types in the corresponding objects in the second Vector.
[中]公共:比较两种类型的向量。如果向量的大小相同,并且第一个向量中的每个类型都可以从第二个向量中相应对象中的类型进行赋值,则返回true。

代码示例

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 *
 * @see #removeQuery(String)
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Return the query from the set of pre-defined queries with the given name and argument types.
 * This allows for common queries to be pre-defined, reused and executed by name.
 * Only returns those queries locally defined, not superclass's queries
 * If only one query exists, it will be returned regardless of the arguments.
 * If multiple queries exist, the first query that has corresponding argument types will be returned
 *
 * @see #getQuery(String)
 */
public DatabaseQuery getLocalQueryByArgumentTypes(String name, List argumentTypes) {
  List queries = (List)getQueries().get(name);
  if (queries == null) {
    return null;
  }
  // Short circuit the simple, most common case of only one query.
  if (queries.size() == 1) {
    return (DatabaseQuery)queries.get(0);
  }
  for (Iterator queriesEnum = queries.iterator(); queriesEnum.hasNext();) {
    DatabaseQuery query = (DatabaseQuery)queriesEnum.next();
    // BUG#2698755
    // This check was backward, we default the type to Object
    // Was checking Object is descendant of String not other way.
    if (Helper.areTypesAssignable(query.getArgumentTypes(), argumentTypes)) {
      return query;
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 *
 * @see #removeQuery(String)
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * PUBLIC:
 * Remove the specific query with the given queryName and argumentTypes.
 *
 * @see #removeQuery(String)
 */
public void removeQuery(String queryName, Vector argumentTypes) {
  Vector queries = (Vector)getQueries().get(queryName);
  if (queries == null) {
    return;
  } else {
    DatabaseQuery query = null;
    for (Enumeration enumtr = queries.elements(); enumtr.hasMoreElements();) {
      query = (DatabaseQuery)enumtr.nextElement();
      if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
        break;
      }
    }
    if (query != null) {
      queries.remove(query);
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
  return query;

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Return the query from the set of pre-defined queries with the given name and argument types.
 * This allows for common queries to be pre-defined, reused and executed by name.
 * Only returns those queries locally defined, not superclass's queries
 * If only one query exists, it will be returned regardless of the arguments.
 * If multiple queries exist, the first query that has corresponding argument types will be returned
 *
 * @see #getQuery(String)
 */
public DatabaseQuery getLocalQueryByArgumentTypes(String name, List argumentTypes) {
  List<DatabaseQuery> queries = getQueries().get(name);
  if (queries == null) {
    return null;
  }
  // Short circuit the simple, most common case of only one query.
  if (queries.size() == 1) {
    return queries.get(0);
  }
  for (DatabaseQuery query : queries) {
    // BUG#2698755
    // This check was backward, we default the type to Object
    // Was checking Object is descendant of String not other way.
    if (Helper.areTypesAssignable(query.getArgumentTypes(), argumentTypes)) {
      return query;
    }
  }
  return null;
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Return the query from the set of pre-defined queries with the given name and argument types.
 * This allows for common queries to be pre-defined, reused and executed by name.
 * Only returns those queries locally defined, not superclass's queries
 * If only one query exists, it will be returned regardless of the arguments.
 * If multiple queries exist, the first query that has corresponding argument types will be returned
 *
 * @see #getQuery(String)
 */
public DatabaseQuery getLocalQueryByArgumentTypes(String name, List argumentTypes) {
  List<DatabaseQuery> queries = getQueries().get(name);
  if (queries == null) {
    return null;
  }
  // Short circuit the simple, most common case of only one query.
  if (queries.size() == 1) {
    return queries.get(0);
  }
  for (DatabaseQuery query : queries) {
    // BUG#2698755
    // This check was backward, we default the type to Object
    // Was checking Object is descendant of String not other way.
    if (Helper.areTypesAssignable(query.getArgumentTypes(), argumentTypes)) {
      return query;
    }
  }
  return null;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
  return query;

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

if (Helper.areTypesAssignable(argumentTypes, query.getArgumentTypes())) {
  return query;

代码示例来源:origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Add the query to the session queries.
 */
protected void addQuery(DatabaseQuery query) {
  Vector queriesByName = (Vector)getQueries().get(query.getName());
  if (queriesByName == null) {
    // lazily create Vector in Hashtable.
    queriesByName = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
    getQueries().put(query.getName(), queriesByName);
  }
  // Check that we do not already have a query that matched it
  for (Enumeration enumtr = queriesByName.elements(); enumtr.hasMoreElements();) {
    DatabaseQuery existingQuery = (DatabaseQuery)enumtr.nextElement();
    if (Helper.areTypesAssignable(query.getArgumentTypes(), existingQuery.getArgumentTypes())) {
      throw ValidationException.existingQueryTypeConflict(query, existingQuery);
    }
  }
  queriesByName.add(query);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Add the query to the session queries.
 */
protected synchronized void addQuery(DatabaseQuery query, boolean nameMustBeUnique) {
  Vector queriesByName = (Vector)getQueries().get(query.getName());
  if (queriesByName == null) {
    // lazily create Vector in Hashtable.
    queriesByName = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
    getQueries().put(query.getName(), queriesByName);
  }
  if (nameMustBeUnique){ // JPA addNamedQuery
    if (queriesByName.size() <= 1){
      queriesByName.clear();
    }else{
      throw new IllegalStateException(ExceptionLocalization.buildMessage("argument_keyed_named_query_with_JPA", new Object[]{query.getName()}));
    }
  }else{
    // Check that we do not already have a query that matched it
    for (Iterator enumtr = queriesByName.iterator(); enumtr.hasNext();) {
      DatabaseQuery existingQuery = (DatabaseQuery)enumtr.next();
      if (Helper.areTypesAssignable(query.getArgumentTypes(), existingQuery.getArgumentTypes())) {
        throw ValidationException.existingQueryTypeConflict(query, existingQuery);
      }
    }
  }
  queriesByName.add(query);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Add the query to the session queries.
 */
protected synchronized void addQuery(DatabaseQuery query, boolean nameMustBeUnique) {
  Vector queriesByName = (Vector)getQueries().get(query.getName());
  if (queriesByName == null) {
    // lazily create Vector in Hashtable.
    queriesByName = org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance();
    getQueries().put(query.getName(), queriesByName);
  }
  if (nameMustBeUnique){ // JPA addNamedQuery
    if (queriesByName.size() <= 1){
      queriesByName.clear();
    }else{
      throw new IllegalStateException(ExceptionLocalization.buildMessage("argument_keyed_named_query_with_JPA", new Object[]{query.getName()}));
    }
  }else{
    // Check that we do not already have a query that matched it
    for (Iterator enumtr = queriesByName.iterator(); enumtr.hasNext();) {
      DatabaseQuery existingQuery = (DatabaseQuery)enumtr.next();
      if (Helper.areTypesAssignable(query.getArgumentTypes(), existingQuery.getArgumentTypes())) {
        throw ValidationException.existingQueryTypeConflict(query, existingQuery);
      }
    }
  }
  queriesByName.add(query);
}

相关文章

Helper类方法