Example usage for com.google.common.primitives Longs contains

List of usage examples for com.google.common.primitives Longs contains

Introduction

In this page you can find the example usage for com.google.common.primitives Longs contains.

Prototype

public static boolean contains(long[] array, long target) 

Source Link

Document

Returns true if target is present as an element anywhere in array .

Usage

From source file:org.janusgraph.util.datastructures.ArraysUtil.java

public static final long[] arrayDifference(long[] arr, long[] subset) {
    long[] res = new long[arr.length - subset.length];
    int pos = 0;//w  w w .  ja  va  2  s  . com
    for (int i = 0; i < arr.length; i++) {
        if (!Longs.contains(subset, arr[i])) {
            res[pos] = arr[i];
            pos++;
        }
    }
    assert pos == res.length;
    return res;
}

From source file:com.b2international.snowowl.snomed.reasoner.model.ConceptDefinitionBuilder.java

/**
 *
 * @param concept/*from   w  w w.  j  a  v  a 2s .  c om*/
 * @param overrideId
 * @param isGeneratedProduct
 * @return
 */
public static ConceptDefinition createDefinition(final Concept concept, final boolean overrideId) {

    final boolean exhaustive = concept.isExhaustive();
    final LongSet disjointUnionIds;

    if (exhaustive) {
        throw new UnsupportedOperationException();
    } else {
        disjointUnionIds = null;
    }

    final Set<ConcreteDomainDefinition> conceptDomainDefinitions = newHashSet();
    final List<SnomedConcreteDataTypeRefSetMember> conceptDomainMembers = concept
            .getConcreteDomainRefSetMembers();
    collectConcreteDomainDefinitions(conceptDomainDefinitions, conceptDomainMembers);

    final boolean primitive = concept.isPrimitive();
    final long conceptId = overrideId ? MOCK_CONCEPT_ID : Long.parseLong(concept.getId());
    final ConceptDefinition result = new ConceptDefinition(conceptDomainDefinitions, conceptId, primitive,
            disjointUnionIds);

    // XXX: role inclusion is not handled

    for (final Relationship relationship : concept.getOutboundRelationships()) {

        if (!relationship.isActive()) {
            continue;
        }

        if (!isDefining(relationship)) {
            continue;
        }

        final Set<ConcreteDomainDefinition> relationshipDomainDefinitions = newHashSet();
        final List<SnomedConcreteDataTypeRefSetMember> relationshipDomainMembers = relationship
                .getConcreteDomainRefSetMembers();
        collectConcreteDomainDefinitions(relationshipDomainDefinitions, relationshipDomainMembers);

        final long typeId = Long.parseLong(relationship.getType().getId());
        final long destinationId = Long.parseLong(relationship.getDestination().getId());

        if (LongConcepts.IS_A_ID == typeId) {
            result.addIsaDefinition(new RelationshipDefinition(destinationId));
            continue;
        }

        final RelationshipDefinition relationshipDefinition = new RelationshipDefinition(
                relationshipDomainDefinitions, typeId, destinationId, relationship.isDestinationNegated(),
                Concepts.UNIVERSAL_RESTRICTION_MODIFIER.equals(relationship.getModifier().getId()));

        if (Longs.contains(LongConcepts.NEVER_GROUPED_ROLE_IDS, typeId) && 0 == relationship.getGroup()) {
            result.addNeverGroupedDefinition(relationshipDefinition, (byte) relationship.getGroup(),
                    (byte) relationship.getUnionGroup());
        } else {
            result.addGroupDefinition(relationshipDefinition, (byte) relationship.getGroup(),
                    (byte) relationship.getUnionGroup());
        }
    }

    return result;
}

From source file:com.b2international.snowowl.snomed.reasoner.server.ontology.DelegateOntology.java

private List<OWLAxiom> createRawAxioms(final long conceptId, final boolean primitive) {

    final Collection<ConcreteDomainFragment> conceptDomainFragments = getReasonerTaxonomyBuilder()
            .getStatedConcreteDomainFragments(conceptId);
    final Set<ConcreteDomainDefinition> conceptDomainDefinitions = newHashSet();

    for (final ConcreteDomainFragment conceptFragment : conceptDomainFragments) {
        conceptDomainDefinitions.add(new ConcreteDomainDefinition(conceptFragment));
    }//from  ww  w .  j a v a 2 s  . c  om

    final ConceptDefinition definition = new ConceptDefinition(conceptDomainDefinitions, conceptId, primitive,
            null);
    final Collection<StatementFragment> statementFragments = getReasonerTaxonomyBuilder()
            .getStatedStatementFragments(conceptId);

    for (final StatementFragment statementFragment : statementFragments) {
        final long statementId = statementFragment.getStatementId();
        final Collection<ConcreteDomainFragment> relationshipDomainFragments = getReasonerTaxonomyBuilder()
                .getStatedConcreteDomainFragments(statementId);
        final Set<ConcreteDomainDefinition> relationshipDomainDefinitions = newHashSet();

        for (final ConcreteDomainFragment relationshipDomainFragment : relationshipDomainFragments) {
            relationshipDomainDefinitions.add(new ConcreteDomainDefinition(relationshipDomainFragment));
        }

        final RelationshipDefinition relationshipDefinition = new RelationshipDefinition(
                relationshipDomainDefinitions, statementFragment.getTypeId(),
                statementFragment.getDestinationId(), statementFragment.isDestinationNegated(),
                statementFragment.isUniversal());

        if (LongConcepts.IS_A_ID == statementFragment.getTypeId()) {
            definition.addIsaDefinition(relationshipDefinition);
        } else if (Longs.contains(LongConcepts.NEVER_GROUPED_ROLE_IDS, statementFragment.getTypeId())
                && 0 == statementFragment.getGroup()) {
            definition.addNeverGroupedDefinition(relationshipDefinition, statementFragment.getGroup(),
                    statementFragment.getUnionGroup());
        } else {
            definition.addGroupDefinition(relationshipDefinition, statementFragment.getGroup(),
                    statementFragment.getUnionGroup());
        }
    }

    final List<OWLAxiom> axioms = newArrayList();
    definition.collect(manager.getOWLDataFactory(), prefixManager, axioms,
            Sets.<OWLClassExpression>newHashSet());
    return axioms;
}