Java 类org.eclipse.xtext.util.Arrays 实例源码

项目:n4js    文件:PreparationStep.java   
@Override
protected void copyReference(EReference eReference, EObject eObject, EObject copyEObject) {
    final boolean needsRewiring = Arrays.contains(REWIRED_REFERENCES, eReference);
    if (needsRewiring) {
        if (!(copyEObject instanceof ReferencingElement_IM)) {
            throw new IllegalStateException(
                    "an EObject with a cross-reference that requires rewiring must have a copy of type ReferencingElement_IM;"
                            + "\nin object: " + eObject
                            + "\nin resource: " + eObject.eResource().getURI());
        }
        rewire(eObject, (ReferencingElement_IM) copyEObject);
        // note: suppress default behavior (references "id", "property", "declaredType" should stay at 'null')
    } else {
        super.copyReference(eReference, eObject, copyEObject);
    }
}
项目:n4js    文件:N4JSProjectExplorerContentProvider.java   
@Override
public Object getParent(Object element) {

    // Required by editor - navigator linking to locate parent item in tree.
    if (element instanceof IProject && workingSetManagerBroker.isWorkingSetTopLevel()) {
        final WorkingSetManager activeManager = workingSetManagerBroker.getActiveManager();
        if (activeManager != null) {
            for (final WorkingSet workingSet : activeManager.getWorkingSets()) {
                final IAdaptable[] elements = workingSet.getElements();
                if (!Arrays2.isEmpty(elements) && Arrays.contains(elements, element)) {
                    return workingSet;
                }
            }
        }
    }

    return super.getParent(element);
}
项目:Infrastructure    文件:Tracing.java   
/**
 * Returns the observables in output sequence. Considers {@link #LIMIT} and {@link #EXCLUDE}.
 * 
 * @param cls the part class to sort the observables (and to cache them for)
 * @param observables the observables related to <code>cls</code>
 * @return the sorted observables
 */
static IObservable[] getObservableSequence(Class<?> cls, Collection<IObservable> observables) {
    IObservable[] result = SEQUENCES.get(cls);
    if (null == result && null != observables) {
        TreeSet<IObservable> tmp = new TreeSet<IObservable>(ObservableComparator.INSTANCE);
        IObservable[] limit = LIMIT.get(cls.getClass());
        IObservable[] exclude = EXCLUDE.get(cls.getClass());
        for (IObservable observable : observables) {
            if ((null == limit || Arrays.contains(limit, observable)) 
                && (null == exclude || !Arrays.contains(exclude, observable))) {
                tmp.add(observable);
            }
        }
        result = new IObservable[tmp.size()];
        SEQUENCES.put(cls, tmp.toArray(result));
    }
    return result;
}
项目:QM-EASyProducer    文件:AlgorithmProfileHelper.java   
/**
 * Adds top level values configured for <code>source</code> to <code>target</code>.
 * 
 * @param cfg the actual configuration holding the values
 * @param source the source project
 * @param target the target project
 * @param exclude the variable names to exclude
 * @return the changed top-level variables ready for freezing
 * @throws CSTSemanticException in case of CST errors
 */
private static List<IFreezable> addTopLevelValues(Configuration cfg, Project source, Project target, 
    String... exclude) throws CSTSemanticException {
    List<IFreezable> result = new ArrayList<IFreezable>();
    for (int e = 0; e < source.getElementCount(); e++) {
        ContainableModelElement elt = source.getElement(e);
        if (elt instanceof DecisionVariableDeclaration) {
            DecisionVariableDeclaration decl = (DecisionVariableDeclaration) elt;
            if (!Arrays.contains(exclude, decl.getName())) {
                IDecisionVariable decVar = cfg.getDecision(decl);
                Value value = decVar.getValue();
                if (null != value && !ConstraintType.isConstraint(decVar.getDeclaration().getType())) {
                    ConstraintSyntaxTree cst = new OCLFeatureCall(new Variable(decl), IvmlKeyWords.ASSIGNMENT, 
                        new ConstantValue(decVar.getValue().clone()));
                    cst.inferDatatype();
                    Constraint constraint = new Constraint(cst, target);
                    target.addConstraint(constraint);
                    result.add(decl);
                }
            }
        }
    }
    return result;
}
项目:n4js    文件:N4JSMemberRedefinitionValidator.java   
private String cfOtherImplementedMembers(MemberMatrix mm, TMember... filteredMembers) {
    String others = validatorMessageHelper.descriptions(
            StreamSupport.stream(mm.implemented().spliterator(), false)
                    .filter(m -> !Arrays.contains(filteredMembers, m))
                    .collect(Collectors.toList()));
    if (others.length() == 0) {
        return "";
    }
    return " Also cf. " + others + ".";
}
项目:n4js    文件:ProjectComparisonEntry.java   
public ProjectComparisonEntry getChildForElementImpl(@SuppressWarnings("hiding") EObject elementImpl) {
    if (elementImpl == null)
        throw new IllegalArgumentException("elementImpl may not be null");
    for (ProjectComparisonEntry currE : getChildren())
        if (Arrays.contains(currE.elementImpl, elementImpl))
            return currE;
    return null;
}
项目:xtext-core    文件:AbstractValidationDiagnostic.java   
/**
 * @param issueData optional user data. May not contain <code>null</code> entries.
 */
protected AbstractValidationDiagnostic(int severity, String message, EObject source, CheckType checkType, String issueCode, String... issueData) {
    if (Arrays.contains(issueData, null)) {
        throw new NullPointerException("issueData may not contain null");
    }
    this.source = source;
    this.severity = severity;
    this.message = message;
    this.issueCode = issueCode;
    this.checkType = checkType;
    this.issueData = issueData;
}
项目:xtext-core    文件:DefaultResourceDescriptionDelta.java   
protected boolean equals(IEObjectDescription oldObj, IEObjectDescription newObj) {
    if (oldObj == newObj)
        return true;
    if (oldObj.getEClass() != newObj.getEClass())
        return false;
    if (oldObj.getName() != null && !oldObj.getName().equals(newObj.getName()))
        return false;
    if (!oldObj.getEObjectURI().equals(newObj.getEObjectURI()))
        return false;
    String[] oldKeys = oldObj.getUserDataKeys();
    String[] newKeys = newObj.getUserDataKeys();
    if (oldKeys.length != newKeys.length)
        return false;
    for (String key : oldKeys) {
        if (!Arrays.contains(newKeys, key))
            return false;
        String oldValue = oldObj.getUserData(key);
        String newValue = newObj.getUserData(key);
        if (oldValue == null) {
            if (newValue != null)
                return false;
        } else if (!oldValue.equals(newValue)) {
            return false;
        }
    }
    return true;
}
项目:xtext-core    文件:XtextLinkingDiagnostic.java   
/**
 * @param data optional user data. May not contain <code>null</code> entries.
 * @throws NullPointerException if node is <code>null</code> or data contains <code>null</code>.
 */
public XtextLinkingDiagnostic(INode node, String message, String code, String... data) {
    if (node == null)
        throw new NullPointerException("node may not be null");
    if (Arrays.contains(data, null)) {
        throw new NullPointerException("data may not contain null");
    }
    this.node = node;
    this.message = message;
    this.code = code;
    this.data = data;
}
项目:xtext-core    文件:ValidationTestHelper.java   
public void assertNoError(final Resource resource, final String issuecode, final String userData) {
    final List<Issue> validate = validate(resource);
    Iterable<Issue> issues = filter(validate, new Predicate<Issue>() {
        @Override
        public boolean apply(Issue input) {
            if (issuecode.equals(input.getCode())) {
                return userData == null || Arrays.contains(input.getData(), userData);
            }
            return false;
        }
    });
    if (!isEmpty(issues))
        fail("Expected no error '" + issuecode + "' but got " + getIssuesAsString(resource, issues, new StringBuilder()));
}
项目:xtext-core    文件:EObjectDescriptionDeltaProvider.java   
protected boolean isUserDataEqual(IEObjectDescription oldObj, IEObjectDescription newObj) {
    String[] oldKeys = oldObj.getUserDataKeys();
    String[] newKeys = newObj.getUserDataKeys();
    if (oldKeys.length != newKeys.length)
        return false;
    for (String key : oldKeys) {
        if (!Arrays.contains(newKeys, key))
            return false;
        String oldValue = oldObj.getUserData(key);
        String newValue = newObj.getUserData(key);
        if (!Objects.equal(oldValue, newValue))
            return false;
    }
    return true;
}
项目:Infrastructure    文件:AbstractFileTrace.java   
/**
 * Trace output for the header line for <code>part</code>.
 * 
 * @param part the part to create the header part for
 * @param prefix additional text to be printed before the name of the columns (may be empty)
 * @param exclude observables to exclude - trace only other others (may be <b>null</b>)
 * @param include observables to include - trace only those (may be <b>null</b>)
 */
protected void traceHeader(SystemPart part, String prefix, IObservable[] exclude, IObservable[] include) {
    IObservable[] sequence = Tracing.getObservableSequence(part);
    for (int o = 0; o < sequence.length; o++) {
        IObservable observable = sequence[o];
        if ((null == include || Arrays.contains(include, observable)) 
            && (null == exclude || !Arrays.contains(exclude, observable))) {
            print(prefix + observable.name());
            printSeparator();
        }
    }
}
项目:n4js    文件:WorkingSetAdapter.java   
@Override
public boolean isVisible() {
    final WorkingSet[] visibleWorkingSets = delegate.getWorkingSetManager().getWorkingSets();
    return Arrays.contains(visibleWorkingSets, delegate);
}
项目:dsl-devkit    文件:ContainerQuery.java   
/**
 * Run a query on a single container.
 *
 * @param container
 *          The container
 * @return The query result.
 */
public Iterable<IEObjectDescription> execute(final IContainer container) { // NOPMD NPathComplexity by WTH on 24.11.10 06:07
  if (domains != null && !domains.isEmpty() && domainMapper != null) {
    IDomain domain = domainMapper.map(container);
    if (domain != null && !domains.contains(domain.getName())) {
      // Query not applicable to this container.
      return ImmutableList.of();
    }
  }

  // Warning: we assume that our Containers and ResourceDescriptions from the index can handle name patterns.
  Iterable<IEObjectDescription> result = namePattern != null ? container.getExportedObjects(getType(), namePattern, doIgnoreCase)
      : container.getExportedObjectsByType(getType());

  if (getUserData() != null && !getUserData().isEmpty()) {
    final Map<String, String> userDataEquals = getUserData();
    final Predicate<IEObjectDescription> userDataPredicate = new Predicate<IEObjectDescription>() {
      @Override
      public boolean apply(final IEObjectDescription input) {
        for (final Entry<String, String> entry : userDataEquals.entrySet()) {
          if (!entry.getValue().equals(input.getUserData(entry.getKey()))) {
            return false;
          }
        }
        return true;
      }
    };
    result = Iterables.filter(result, userDataPredicate);
  }

  result = Iterables.transform(result, new Function<IEObjectDescription, IEObjectDescription>() {
    @Override
    public IEObjectDescription apply(final IEObjectDescription from) {
      String[] keys = from.getUserDataKeys();
      if (keys.length == 0 || !Arrays.contains(keys, DetachableEObjectDescription.ALLOW_LOOKUP)) {
        LOGGER.error("Found object description '" + from.getQualifiedName() + "' at " + from.getEObjectURI() + ", but lookup is not allowed!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      return keys.length == 0 ? from : new ProxyFactoryEObjectDescription(from);
    }
  });

  return result;
}
项目:statecharts    文件:FilteringMenuManager.java   
protected boolean allowItem(IContributionItem itemToAdd) {
    if (itemToAdd.getId() != null && Arrays.contains(exclusionSet, itemToAdd.getId()))
        itemToAdd.setVisible(false);
    return super.allowItem(itemToAdd);
}
项目:statecharts    文件:DiagramPartitioningEditor.java   
protected boolean allowItem(IContributionItem itemToAdd) {
    if (Arrays.contains(exclude, itemToAdd.getId())) {
        itemToAdd.setVisible(false);
    }
    return true;
}
项目:Infrastructure    文件:AbstractFileTrace.java   
/**
 * Traces the values observed for <code>part</code>.
 * 
 * @param part the part to trace (may be <b>null</b> if already gone)
 * @param partCls the class of part, ignored if part is not <b>null</b>, otherwise used to determine the sequence
 * @param exclude observables to exclude - trace only other others (may be <b>null</b>)
 * @param include observables to include - trace only those (may be <b>null</b>)
 * @param taskId if given, trace only observations for <code>taskId</code>, print <code>part</code>-level 
 *     observables if <b>null</b> 
 */
protected void trace(SystemPart part, Class<? extends SystemPart> partCls, IObservable[] exclude, 
    IObservable[] include, Integer taskId) {
    ComponentKey host = null;
    IObservable[] sequence;
    if (null != part) {
        sequence = Tracing.getObservableSequence(part);
    } else {
        sequence = Tracing.getObservableSequence(partCls, null); // if not seen so far, no (specific) sequence is ok
    }
    for (int o = 0; o < sequence.length; o++) {
        IObservable observable = sequence[o];
        if ((null == include || Arrays.contains(include, observable)) 
            && (null == exclude || !Arrays.contains(exclude, observable))) {
            boolean printed = false;
            if (null != taskId && null != part) {
                ComponentKey key = null;
                Set<Object> keys = part.getComponentKeys(observable);
                for (Object k : keys) {
                    if (k instanceof ComponentKey && ((ComponentKey) k).getTaskId() == taskId) {
                        key = (ComponentKey) k;
                        break;
                    }
                }
                if (null != key) {
                    print(part.getObservedValue(observable, key));
                    printed = true;
                    if (null == host) {
                        host = key;
                    }
                } 
            } 
            if (!printed) {
                if (null != part && part.hasValue(observable)) {
                    print(part.getObservedValue(observable));
                    printed = true;
                } 
                if (!printed) {
                    print("");
                }
            }
            printSeparator();
        }
    }
    if (null != host) {
        print(host.getHostName());
        printSeparator();
    }
}
项目:PDFReporter-Studio    文件:FilteringMenuManager.java   
protected boolean allowItem(IContributionItem itemToAdd) {
    if (itemToAdd.getId() != null && Arrays.contains(exclusionSet, itemToAdd.getId()))
        itemToAdd.setVisible(false);
    return super.allowItem(itemToAdd);
}
项目:EASyProducer    文件:BasicModelLoadingListener.java   
/**
 * Whether <code>type</code> is in {@link #types}.
 * 
 * @param type the type to look for
 * @return <code>true</code> if type is a contained type, <code>false</code> else
 */
private boolean inTypes(Type type) {
    return null == types || Arrays.contains(types, type);
}