org.openide.util.Union2.second()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(89)

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

Union2.second介绍

[英]Retrieve the union member of the second type.
[中]

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

creators = resolvers.second();
  if (creators.contains (Thread.currentThread())) {
if (resolvers != null && resolvers.hasSecond() && resolvers.second() == creators) {

代码示例来源:origin: org.netbeans.api/org-openide-util

return _res.first();
} else {
  Throwable e = _res.second();
  if (e instanceof RuntimeException) {
    throw (RuntimeException) e;

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

return _res.first();
} else {
  Throwable e = _res.second();
  if (e instanceof RuntimeException) {
    throw (RuntimeException) e;

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@CheckForNull
private Collection<? extends TypeScope> typesFromUnion() {
  if (typeNameScopes != null) {
    if (typeNameScopes.hasSecond() && typeNameScopes.second() != null) {
      return typeNameScopes.second();
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

private ModelElement getModelElemnt() {
  return element.hasSecond() ? element.second() : null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-projectapi-nb

public boolean is(Union2<Reference<Project>,LoadStatus> o) {
  return o != null && o.hasSecond() && o.second() == this;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

void putProfile(
  @NonNull final  Key key,
  @NonNull final Union2<Profile,String> profile) {
  if (LOG.isLoggable(Level.FINER)) {
    LOG.log(
      Level.FINER,
      "cache[{0}]<-{1}",   //NOI18N
      new Object[]{
        key,
        profile.hasFirst() ? profile.first() : profile.second()
      });
  }
  cache.put(key,profile);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private static void processNodes(Union2<List<Node>,Node[]> unionNodes[]) {
  for (int i = 0; i < unionNodes.length; i++) {
    Union2<List<Node>,Node[]> node = unionNodes[i];
    if (node == null) {
      continue;
    }
    List<Node> nodeList = node.first();
    assert !nodeList.isEmpty();
    Node[] nodesArray = node.first().toArray(
                    new Node[nodeList.size()]);
    for (Node nodeArrayElem : nodesArray) {
      nodeArrayElem.processChildren();
    }
    unionNodes[i] = Union2.<List<Node>,Node[]>createSecond(nodesArray);
    assert unionNodes[i].second().length != 0;
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@CheckForNull
Union2<Profile,String> getProfile(@NonNull final Key key) {
  final Union2<Profile,String> res = cache.get(key);
  if (LOG.isLoggable(Level.FINER)) {
    LOG.log(
      Level.FINER,
      "cache[{0}]->{1}",  //NOI18N
      new Object[]{
        key,
        res.hasFirst() ? res.first() : res.second()
      });
  }
  return res;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@Override
public Collection<? extends String> getSuperClassNames() {
  List<String> retval =  new ArrayList<>();
  if (superClass != null) {
    String supeClsName = superClass.hasFirst() ? superClass.first() : null;
    if (supeClsName != null) {
      return Collections.singletonList(supeClsName);
    }
    List<ClassScopeImpl> supeClasses =  Collections.emptyList();
    if (superClass.hasSecond()) {
      supeClasses = superClass.second();
    }
    for (ClassScopeImpl cls : supeClasses) {
      retval.add(cls.getName());
    }
  }
  return retval;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

String typeNameFromUnion() {
  if (typeNameScopes != null) {
    if (typeNameScopes.hasFirst() && typeNameScopes.first() != null) {
      return typeNameScopes.first();
    } else if (typeNameScopes.hasSecond() && typeNameScopes.second() != null) {
      TypeScope type = ModelUtils.getFirst(typeNameScopes.second());
      return type != null ? type.getName() : null;
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private <T extends FileComponent> T getFileComponent(Union2<T, WeakContainer<T>> ref) {
  if (ref.hasFirst()) {
    assert !persistent : "non persistent must have hard reference";
    return ref.first();
  } else {
    assert persistent : "persistent must have weak reference";
    return ref.second().getContainer();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@NonNull
@Override
public Collection<? extends ClassScope> getSuperClasses() {
  List<ClassScope> retval = null;
  if (superClass.hasSecond() && superClass.second() != null) {
    return superClass.second();
  }
  assert superClass.hasFirst();
  String superClasName = superClass.first();
  if (possibleFQSuperClassNames != null && possibleFQSuperClassNames.size() > 0) {
    retval = new ArrayList<>();
    for (QualifiedName qualifiedName : possibleFQSuperClassNames) {
      retval.addAll(IndexScopeImpl.getClasses(qualifiedName, this));
    }
  }
  if (retval == null && superClasName != null) {
    return IndexScopeImpl.getClasses(QualifiedName.create(superClasName), this);
  }
  return retval != null ? retval : Collections.<ClassScopeImpl>emptyList();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private <T extends FileComponent> Key getFileComponentKey(Union2<T, WeakContainer<T>> ref) {
  if (ref.hasFirst()) {
    assert !persistent : "non persistent must have hard reference";
    return ref.first().getKey();
  } else {
    assert persistent : "persistent must have weak reference";
    return ref.second().getKey();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-repository

@Override protected Node createNodeForKey(Union2<RepositoryInfo,QueryRequest> key) {
  if (key.hasFirst()) {
    return new RepositoryNode(key.first());
  } else {
    return new FindResultsNode(key.second());
  }
}
@Override protected void addNotify() {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

public OwnerInfo getMatchingInfo(String relativePath) {
  String firstPartOfPath = getFirstPartOfPath(relativePath);
  int topNodeIndex = getTopNodeIndex(firstPartOfPath);
  Union2<List<Node>,Node[]> topNodeUnion = topNodes[topNodeIndex];
  if (topNodeUnion == null) {
    return null;
  }
  Node[] topNode = topNodeUnion.second();
  if (topNode == null) {
    assert false;
    return null;
  }
  OwnerInfo ownerInfo = findInfo(relativePath,
                  firstPartOfPath,
                  topNode);
  if (ownerInfo != null && ownerInfo != OwnerInfo.NULL_OWNER_INFO) {
    return ownerInfo;
  } else {
    return null;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

ModelElementImpl(Scope inScope, String name,
    Union2<String/*url*/, FileObject> file, OffsetRange offsetRange, PhpElementKind kind,
    PhpModifiers modifiers, boolean isDeprecated) {
  if (name == null || file == null || kind == null || modifiers == null) {
    throw new IllegalArgumentException("null for name | fo | kind: " + name + " | " + file + " | " + kind);
  }
  assert file.hasFirst() || file.hasSecond();
  if (file.hasFirst() && file.first() != null) {
    this.filenameUrl = file.first();
  } else if (file.hasSecond() && file.second() != null) {
    this.filenameUrl = file.second().toURL().toExternalForm();
  } else {
    this.filenameUrl = "";
  }
  this.inScope = inScope;
  this.name = name;
  this.offsetRange = offsetRange;
  this.kind = kind;
  this.file = file;
  this.modifiers = modifiers;
  this.isDeprecated = isDeprecated;
  if (inScope instanceof ScopeImpl && !(this instanceof AssignmentImpl)/* && !(inScope instanceof IndexScope)*/) {
    ((ScopeImpl) inScope).addElement(this);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

static Model getModel(Union2<Document, FileObject> document2Parse) {
  Parameters.notNull("document2Parse", document2Parse); //NOI18N
  ModelProviderTask modelProvider = new ModelProviderTask();
  if (document2Parse.hasFirst()) {
    try {
      Source source = Source.create(document2Parse.first());
      ParserManager.parseWhenScanFinished(Collections.singleton(source), modelProvider);
    } catch (ParseException e) {
      LOG.log(Level.WARNING, null, e);
    }
  } else if (document2Parse.hasSecond()) {
    Source source = Source.create(document2Parse.second());
    try {
      ParserManager.parseWhenScanFinished(Collections.singletonList(source), modelProvider);
    } catch (ParseException ex) {
      LOG.log(Level.WARNING, null, ex);
    }
  }
  return modelProvider.getModel();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@CheckForNull
@Override
public QualifiedName getSuperClassName() {
  if (superClass != null) {
    List<? extends ClassScope> retval = superClass.hasSecond() ? superClass.second() : null; //this
    if (retval == null) {
      assert superClass.hasFirst();
      String superClasName = superClass.first();
      if (superClasName != null) {
        return QualifiedName.create(superClasName);
      }
    } else if (retval.size() > 0) {
      ClassScope cls = ModelUtils.getFirst(retval);
      if (cls != null) {
        return QualifiedName.create(cls.getName());
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@CheckForNull
@Override
public FileObject getFileObject() {
  FileObject fileObject = null;
  synchronized (ModelElementImpl.class) {
    if (file != null) {
      fileObject = file.hasSecond() ? file.second() : null;
    }
  }
  if (fileObject == null && file.hasFirst()) {
    String fileUrl = file.first();
    if (StringUtils.hasText(fileUrl)) {
      fileObject = PhpElementImpl.resolveFileObject(fileUrl);
      synchronized (ModelElementImpl.class) {
        if (fileObject != null) {
          file = Union2.createSecond(fileObject);
        }
      }
    }
  }
  return fileObject;
}

相关文章