Example usage for org.apache.commons.lang3.tuple ImmutableTriple ImmutableTriple

List of usage examples for org.apache.commons.lang3.tuple ImmutableTriple ImmutableTriple

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple ImmutableTriple ImmutableTriple.

Prototype

public ImmutableTriple(final L left, final M middle, final R right) 

Source Link

Document

Create a new triple instance.

Usage

From source file:com.minlia.cloud.framework.test.common.web.AbstractSearchLiveTest.java

@Override
@Test/* ww w  .  ja  va2s  . c o  m*/
public final void givenResourceExists_whenResourceIsSearchedByNegatedId_thenOperationIsSuccessful() {
    final T existingResource = getApi().create(createNewEntity());

    final Triple<String, ClientOperation, String> negatedIdConstraint = new ImmutableTriple<String, ClientOperation, String>(
            SearchField.id.toString(), NEG_EQ, existingResource.getId().toString());

    // When
    final Response searchResponse = getApi().searchAsResponse(negatedIdConstraint, null);

    // Then
    assertThat(searchResponse.getStatusCode(), is(200));
}

From source file:com.minlia.cloud.framework.test.common.service.search.AbstractSearchIntegrationTest.java

@Override
public final void givenResourceExists_whenResourceIsSearchedByNegatedId_thenResourceIsNotFound() {
    // Given// www  . ja  va2 s  .c  o m
    final T existingResource = persistNewEntity();

    // When
    final Triple<String, ClientOperation, String> negatedIdConstraint = new ImmutableTriple<String, ClientOperation, String>(
            SearchField.id.toString(), NEG_EQ, existingResource.getId().toString());
    final List<T> searchResults = getApi().searchAll(negatedIdConstraint, null);

    // Then
    assertThat(searchResults, not(hasItem(existingResource)));
}

From source file:com.minlia.cloud.framework.test.common.web.AbstractSearchLiveTest.java

@Override
@Test//from   ww w .j a  v a2s  .  c om
public final void givenResourceAndOtherResourcesExists_whenResourceIsSearchedByNegatedId_thenResourcesAreFound() {
    final T existingResource1 = getApi().create(createNewEntity());
    final T existingResource2 = getApi().create(createNewEntity());

    // When
    final ImmutableTriple<String, ClientOperation, String> idConstraint = new ImmutableTriple<String, ClientOperation, String>(
            SearchField.id.toString(), NEG_EQ, existingResource1.getId().toString());
    final List<T> searchResults = getApi().searchAll(idConstraint);

    // Then
    assertThat(searchResults, not(hasItem(existingResource1)));
    assertThat(searchResults, hasItem(existingResource2));
}

From source file:main.java.RMDupper.java

public static void queueOrOutput(DupStats dupStats, OccurenceCounterMerged occurenceCounterMerged,
        SAMFileWriter outputSam, Boolean allReadsAsMerged,
        PriorityQueue<ImmutableTriple<Integer, Integer, SAMRecord>> recordBuffer,
        PriorityQueue<ImmutableTriple<Integer, Integer, SAMRecord>> duplicateBuffer, Set<String> discardSet,
        SAMRecord curr) {/*ww w  .  j a  v  a2  s  .c  o  m*/
    //Don't do anything with unmapped reads, just write them into the output!
    if (curr.getReadUnmappedFlag() || curr.getMappingQuality() == 0) {
        outputSam.addAlignment(curr);
    } else {
        if (recordBuffer.size() > 0 && recordBuffer.peek().middle < curr.getAlignmentStart()) {
            checkForDuplication(dupStats, occurenceCounterMerged, outputSam, allReadsAsMerged, recordBuffer,
                    duplicateBuffer, discardSet);
        }
        recordBuffer.add(new ImmutableTriple<Integer, Integer, SAMRecord>(curr.getAlignmentStart(),
                curr.getAlignmentEnd(), curr));
    }
}

From source file:com.minlia.cloud.framework.test.common.service.search.AbstractSearchIntegrationTest.java

@Override
@Test//from   www. j  a v  a 2 s.  co  m
public final void whenSearchByStartsWithIsPerformed_thenNoExceptions() {
    // When
    final ImmutableTriple<String, ClientOperation, String> nameConstraint = new ImmutableTriple<String, ClientOperation, String>(
            SearchField.name.toString(), ClientOperation.STARTS_WITH, randomAlphabetic(8));
    getApi().searchAll(nameConstraint);
}

From source file:com.minlia.cloud.framework.test.common.service.search.AbstractSearchIntegrationTest.java

@Override
@Test/*  ww w .j  a va2s.  c  o m*/
public final void whenSearchByEndsWithIsPerformed_thenNoExceptions() {
    // When
    final ImmutableTriple<String, ClientOperation, String> nameConstraint = new ImmutableTriple<String, ClientOperation, String>(
            SearchField.name.toString(), ClientOperation.ENDS_WITH, randomAlphabetic(8));
    getApi().searchAll(nameConstraint);
}

From source file:com.minlia.cloud.framework.test.common.service.search.AbstractSearchIntegrationTest.java

protected final Triple<String, ClientOperation, String> createNameConstraint(final ClientOperation operation,
        final String nameValue) {
    return new ImmutableTriple<String, ClientOperation, String>(QueryConstants.NAME, operation, nameValue);
}

From source file:blusunrize.immersiveengineering.api.ApiUtils.java

public static boolean raytraceAlongCatenaryRelative(Connection conn,
        Predicate<Triple<BlockPos, Vec3d, Vec3d>> shouldStop, Consumer<Triple<BlockPos, Vec3d, Vec3d>> close,
        Vec3d vStart, Vec3d vEnd) {/*from  w  w  w. ja  v a2 s  .c o m*/
    conn.getSubVertices(vStart, vEnd);
    HashMap<BlockPos, Vec3d> halfScanned = new HashMap<>();
    HashSet<BlockPos> done = new HashSet<>();
    HashSet<Triple<BlockPos, Vec3d, Vec3d>> near = new HashSet<>();
    Vec3d across = vEnd.subtract(vStart);
    across = new Vec3d(across.x, 0, across.z);
    double lengthHor = across.length();
    halfScanned.put(conn.start, vStart);
    halfScanned.put(conn.end, vEnd);
    //Raytrace X&Z
    for (int dim = 0; dim <= 2; dim += 2) {
        int start = (int) Math.ceil(Math.min(getDim(vStart, dim), getDim(vEnd, dim)));
        int end = (int) Math.ceil(Math.max(getDim(vStart, dim), getDim(vEnd, dim)));
        for (int i = start; i < end; i++) {
            double factor = (i - getDim(vStart, dim)) / getDim(across, dim);
            Vec3d pos = conn.getVecAt(factor);

            if (handleVec(pos, pos, 0, halfScanned, done, shouldStop, near, conn.start))
                return false;
        }
    }
    //Raytrace Y
    boolean vertical = vStart.x == vEnd.x && vStart.z == vEnd.z;
    if (vertical) {
        for (int y = (int) Math.ceil(Math.min(vStart.y, vEnd.y)); y <= Math
                .floor(Math.max(vStart.y, vEnd.y)); y++) {
            Vec3d pos = new Vec3d(vStart.x, y, vStart.z);
            if (handleVec(pos, pos, 0, halfScanned, done, shouldStop, near, conn.start))
                return false;
        }
    } else {
        double min = conn.catA + conn.catOffsetY + vStart.y;
        for (int i = 0; i < 2; i++) {
            double factor = i == 0 ? 1 : -1;
            double max = i == 0 ? vEnd.y : vStart.y;
            for (int y = (int) Math.ceil(min); y <= Math.floor(max); y++) {
                double yReal = y - vStart.y;
                double posRel;
                Vec3d pos;
                posRel = (factor * acosh((yReal - conn.catOffsetY) / conn.catA) * conn.catA + conn.catOffsetX)
                        / lengthHor;
                pos = new Vec3d(vStart.x + across.x * posRel, y, vStart.z + across.z * posRel);

                if (posRel >= 0 && posRel <= 1
                        && handleVec(pos, pos, 0, halfScanned, done, shouldStop, near, conn.start))
                    return false;
            }
        }
    }
    for (Triple<BlockPos, Vec3d, Vec3d> p : near)
        close.accept(p);
    for (Map.Entry<BlockPos, Vec3d> p : halfScanned.entrySet())
        if (shouldStop.test(new ImmutableTriple<>(p.getKey(), p.getValue(), p.getValue())))
            return false;
    return true;
}

From source file:com.minlia.cloud.framework.test.common.service.search.AbstractSearchIntegrationTest.java

protected final Triple<String, ClientOperation, String> createIdConstraint(final ClientOperation operation,
        final Long idValue) {
    return new ImmutableTriple<String, ClientOperation, String>(QueryConstants.ID, operation,
            idValue.toString());/*ww w .j  av  a  2s .c om*/
}

From source file:blusunrize.immersiveengineering.api.ApiUtils.java

private static boolean handlePos(Vec3d pos, BlockPos posB, HashMap<BlockPos, Vec3d> halfScanned,
        HashSet<BlockPos> done, Predicate<Triple<BlockPos, Vec3d, Vec3d>> shouldStop,
        HashSet<Triple<BlockPos, Vec3d, Vec3d>> near) {
    final double DELTA_NEAR = .3;
    if (!done.contains(posB)) {
        if (halfScanned.containsKey(posB) && !pos.equals(halfScanned.get(posB))) {
            Triple<BlockPos, Vec3d, Vec3d> added = new ImmutableTriple<>(posB, halfScanned.get(posB), pos);
            boolean stop = shouldStop.test(added);
            done.add(posB);//from  w  w  w . ja v a 2  s .com
            halfScanned.remove(posB);
            near.removeIf((t) -> t.getLeft().equals(posB));
            if (stop)
                return true;
            for (int i = 0; i < 3; i++) {
                double coord = getDim(pos, i);
                double diff = coord - Math.floor(coord);
                if (diff < DELTA_NEAR)
                    near.add(
                            new ImmutableTriple<>(offsetDim(posB, i, -1), added.getMiddle(), added.getRight()));
                diff = Math.ceil(coord) - coord;
                if (diff < DELTA_NEAR)
                    near.add(new ImmutableTriple<>(offsetDim(posB, i, 1), added.getMiddle(), added.getRight()));
            }
        } else {
            halfScanned.put(posB, pos);
        }
    }
    return false;
}