コード例 #1
0
  /**
   * Returns the adapter of the specified type.
   *
   * @param anObject
   * @param adapters list of adapters to search.
   * @param type the type of adapter.
   * @return an adapter from the list or null.
   */
  public static Adapter getAdapter(EObject anObject, List adapters, Object type) {

    Object[] adaptArray = ((EAdapterList) adapters).data();
    if (adaptArray == null) return null;
    for (int i = 0; i < adaptArray.length; i++) {
      Adapter adapter = (Adapter) adaptArray[i];
      if (adapter != null && adapter.isAdapterForType(type)) {
        return adapter;
      }
    }
    return null;
  }
コード例 #2
0
ファイル: PivotUtil.java プロジェクト: matterche/ocl
 public static <T> T getAdapter(Class<T> adapterClass, List<Adapter> eAdapters) {
   Adapter adapter = EcoreUtil.getAdapter(eAdapters, adapterClass);
   if (adapter == null) {
     return null;
   }
   if (!adapterClass.isAssignableFrom(adapter.getClass())) {
     throw new ClassCastException(
         adapter.getClass().getName() + " is not assignable to " + adapterClass.getName());
   }
   @SuppressWarnings("unchecked")
   T castAdapter = (T) adapter;
   return castAdapter;
 }
コード例 #3
0
 private void notifyChildren(Notification notification) {
   for (int i = 0; i < getChildren().size(); i++) {
     Adapter a = (Adapter) getChildren().get(i);
     a.notifyChanged(notification);
   }
 }