當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair.getValue1方法代碼示例

本文整理匯總了Java中org.javatuples.Pair.getValue1方法的典型用法代碼示例。如果您正苦於以下問題:Java Pair.getValue1方法的具體用法?Java Pair.getValue1怎麽用?Java Pair.getValue1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.javatuples.Pair的用法示例。


在下文中一共展示了Pair.getValue1方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: show

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Constructs and displays dialog based on the FXML at the specified URL
 * 
 * @param url
 *            the location of the FXML file, relative to the
 *            {@code sic.nmsu.javafx} package
 * @param stateInit
 *            a consumer used to configure the controller before FXML injection
 * @return
 */
public static <R, C extends FXDialogController<R>> R show(String url, Consumer<C> stateInit) {
	final Pair<Parent, C> result = FXController.get(url, stateInit);
	final Parent view = result.getValue0();
	final C ctrl = result.getValue1();

	final Dialog<R> dialog = new Dialog<>();
	dialog.titleProperty().bind(ctrl.title);

	final DialogPane dialogPane = dialog.getDialogPane();
	dialogPane.setContent(view);
	dialogPane.getButtonTypes().add(ButtonType.CLOSE);

	final Stage window = (Stage) dialogPane.getScene().getWindow();
	window.getIcons().add(new Image("images/recipe_icon.png"));

	final Node closeButton = dialogPane.lookupButton(ButtonType.CLOSE);
	closeButton.managedProperty().bind(closeButton.visibleProperty());
	closeButton.setVisible(false);

	ctrl.dialog = dialog;
	ctrl.dialog.showAndWait();

	return ctrl.result;
}
 
開發者ID:NMSU-SIC-Club,項目名稱:JavaFX_Tutorial,代碼行數:35,代碼來源:FXDialogController.java

示例2: tryDrainNextWaiting

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Completes the next waiting future if there is one.
 */
private synchronized void tryDrainNextWaiting(final boolean force) {
    // need to peek because the number of available items needs to be >= the expected size for that future. if not
    // it needs to keep waiting
    final Pair<CompletableFuture<List<Result>>, Integer> nextWaiting = waiting.peek();
    if (nextWaiting != null && (force || (resultLinkedBlockingQueue.size() >= nextWaiting.getValue1() || readComplete.isDone()))) {
        final int items = nextWaiting.getValue1();
        final CompletableFuture<List<Result>> future = nextWaiting.getValue0();
        final List<Result> results = new ArrayList<>(items);
        resultLinkedBlockingQueue.drainTo(results, items);

        // it's important to check for error here because a future may have already been queued in "waiting" prior
        // to the first response back from the server. if that happens, any "waiting" futures should be completed
        // exceptionally otherwise it will look like success.
        if (null == error.get())
            future.complete(results);
        else
            future.completeExceptionally(error.get());

        waiting.remove(nextWaiting);
    }
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:25,代碼來源:ResultQueue.java

示例3: channelRead0

import org.javatuples.Pair; //導入方法依賴的package包/類
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final Pair<RequestMessage, ThrowingConsumer<Context>> objects) throws Exception {
    final RequestMessage msg = objects.getValue0();
    final ThrowingConsumer<Context> op = objects.getValue1();
    final Context gremlinServerContext = new Context(msg, ctx,
            settings, graphManager, gremlinExecutor, scheduledExecutorService);

    try {
        op.accept(gremlinServerContext);
    } catch (OpProcessorException ope) {
        // Ops may choose to throw OpProcessorException or write the error ResponseMessage down the line
        // themselves
        logger.warn(ope.getMessage(), ope);
        ctx.writeAndFlush(ope.getResponseMessage());
    } catch (Exception ex) {
        // It is possible that an unplanned exception might raise out of an OpProcessor execution. Build a general
        // error to send back to the client
        logger.warn(ex.getMessage(), ex);
        ctx.writeAndFlush(ResponseMessage.build(msg)
                .code(ResponseStatusCode.SERVER_ERROR)
                .statusMessage(ex.getMessage()).create());
    } finally {
        ReferenceCountUtil.release(objects);
    }
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:26,代碼來源:OpExecutorHandler.java

示例4: getNumberOfAddedDatesOfParticularMonthAndYearFromDB

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Gets the number of added dates of particular month and year from db.
 *
 * @param date the date
 * @return the number of added dates of particular month and year from db
 */
public int getNumberOfAddedDatesOfParticularMonthAndYearFromDB(Date date) {
	Pair<Calendar, Calendar> from_to = MyDateUtils.getMaxAndMinOfMonth(date);
	Calendar from = from_to.getValue0();
	Calendar to = from_to.getValue1();	
	
	HibernateSupport.beginTransaction();
	
	long values_size = (long)HibernateSupport.getCurrentSession().createCriteria(MarketValue.class)
			.add(Restrictions.eq("company", this))
			.add(Restrictions.between("date", from.getTime(), to.getTime()))
			.setProjection(Projections.rowCount())
			.uniqueResult();
	
	HibernateSupport.commitTransaction();
	
	return (int) values_size;
}
 
開發者ID:mattmagic149,項目名稱:AnSoMia,代碼行數:24,代碼來源:Company.java

示例5: channelRead0

import org.javatuples.Pair; //導入方法依賴的package包/類
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final Pair<RequestMessage, ThrowingConsumer<Context>> objects) throws Exception {
    final RequestMessage msg = objects.getValue0();
    final ThrowingConsumer<Context> op = objects.getValue1();
    final Context gremlinServerContext = new Context(msg, ctx,
            settings, graphManager, gremlinExecutor, scheduledExecutorService);

    try {
        op.accept(gremlinServerContext);
    } catch (OpProcessorException ope) {
        // Ops may choose to throw OpProcessorException or write the error ResponseMessage down the line
        // themselves
        logger.warn(ope.getMessage(), ope);
        ctx.writeAndFlush(ope.getResponseMessage());
    } catch (Exception ex) {
        // It is possible that an unplanned exception might raise out of an OpProcessor execution. Build a general
        // error to send back to the client
        logger.warn(ex.getMessage(), ex);
        ctx.writeAndFlush(ResponseMessage.build(msg)
                .code(ResponseStatusCode.SERVER_ERROR)
                .statusAttributeException(ex)
                .statusMessage(ex.getMessage()).create());
    } finally {
        ReferenceCountUtil.release(objects);
    }
}
 
開發者ID:apache,項目名稱:tinkerpop,代碼行數:27,代碼來源:OpExecutorHandler.java

示例6: fieldsByName

import org.javatuples.Pair; //導入方法依賴的package包/類
private static <E extends Element> Map<String, Field> fieldsByName(Pair<Class, Predicate<Field>>
    predicatedType) {
  Class<E> elementType = predicatedType.getValue0();
  Predicate<Field> predicate = predicatedType.getValue1();
  List<Field> allFields = Arrays.asList(getAllFields(elementType));
  allFields.forEach(field -> {
    field.setAccessible(true);
  });
  Map<String, Field> fieldMap = allFields.stream()
      .filter(field -> predicate.test(field) && !isHiddenField(field))
      .collect(Collectors.toMap(Field::getName, Function.identity()));
  return fieldMap;
}
 
開發者ID:karthicks,項目名稱:gremlin-ogm,代碼行數:14,代碼來源:Fields.java

示例7: showTasks

import org.javatuples.Pair; //導入方法依賴的package包/類
public void showTasks(Pair<DiffUtil.DiffResult, List<Task>> pairOfDiffResultAndTasks, TasksFilterType filterType) {
    if(tasksAdapter != null) {
        DiffUtil.DiffResult diffResult = pairOfDiffResultAndTasks.getValue0();
        List<Task> tasks = pairOfDiffResultAndTasks.getValue1();
        tasksAdapter.setData(tasks);
        diffResult.dispatchUpdatesTo(tasksAdapter);
        if(tasks.isEmpty()) {
            filterType.showEmptyViews(this);
        } else {
            hideEmptyViews();
        }
    }
}
 
開發者ID:Zhuinden,項目名稱:navigator,代碼行數:14,代碼來源:TasksView.java

示例8: DetachedEdge

import org.javatuples.Pair; //導入方法依賴的package包/類
public DetachedEdge(final Object id, final String label,
                    final Map<String, Object> properties,
                    final Pair<Object, String> outV,
                    final Pair<Object, String> inV) {
    super(id, label);
    this.outVertex = new DetachedVertex(outV.getValue0(), outV.getValue1(), Collections.emptyMap());
    this.inVertex = new DetachedVertex(inV.getValue0(), inV.getValue1(), Collections.emptyMap());
    if (!properties.isEmpty()) {
        this.properties = new HashMap<>();
        properties.entrySet().stream().forEach(entry -> this.properties.put(entry.getKey(), Collections.singletonList(new DetachedProperty<>(entry.getKey(), entry.getValue(), this))));
    }
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:13,代碼來源:DetachedEdge.java

示例9: encodeKey

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Encodes a string to be safe for use as a MongoDB field name.
 * @param key the unencoded key.
 * @return the encoded key.
 */
public static String encodeKey(final String key) {
    String encodedKey = key;
    for (final Pair<String, String> pair : ESCAPE_CHARACTERS) {
        final String unescapedCharacter = pair.getValue0();
        final String escapedCharacter = pair.getValue1();
        encodedKey = encodedKey.replace(unescapedCharacter, escapedCharacter);
    }

    return encodedKey;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:16,代碼來源:MongoDbSafeKey.java

示例10: decodeKey

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Decodes a MongoDB safe field name to an unencoded string.
 * @param key the encoded key.
 * @return the unencoded key.
 */
public static String decodeKey(final String key) {
    String decodedKey = key;
    for (final Pair<String, String> pair : UNESCAPE_CHARACTERS) {
        final String unescapedCharacter = pair.getValue0();
        final String escapedCharacter = pair.getValue1();
        decodedKey = decodedKey.replace(escapedCharacter, unescapedCharacter);
    }

    return decodedKey;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:16,代碼來源:MongoDbSafeKey.java

示例11: load

import org.javatuples.Pair; //導入方法依賴的package包/類
@Override
protected String load() {
	if (joinerSupplier == null || joinerSupplier.get() == null) {
		return null;
	}
	
	List<Object> values = Lists.newLinkedList();
	for (Pair<IModel<?>, Condition> conditionnalModel : conditionnalModels) {
		if (conditionnalModel.getValue1() == null || conditionnalModel.getValue1().applies()) {
			values.add(conditionnalModel.getValue0().getObject());
		}
	}
	
	return joinerSupplier.get().join(values);
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:16,代碼來源:JoinerModel.java

示例12: runHex

import org.javatuples.Pair; //導入方法依賴的package包/類
/**
 * Runs a macro, treating the sequence as a hex sequence.
 * @param macro
 */
private void runHex(Macro macro) {

    Pair<List<Byte>, EncodingUtils.ReturnId> result = EncodingUtils.hexStringToByteArray(macro.sequence.get());
    List<Byte> bytes = result.getValue0();
    EncodingUtils.ReturnId returnId = result.getValue1();

    switch(returnId) {
        case OK:
            break;
        case STRING_DID_NOT_HAVE_EVEN_NUMBER_OF_CHARS:
            model.status.addErr("Macro hex string \"" + macro.sequence.get() + "\" does not have an even number of characters.");
            return;
        case INVALID_CHAR:
            model.status.addErr("Macro hex string \"" + macro.sequence.get() + "\" contains invalid chars (must only contain numbers or the letters A-F).");
            return;
        default:
            throw new RuntimeException("ReturnCode was not recognised.");
    }

    byte[] byteArray = new byte[bytes.size()];
    for(int i = 0; i < bytes.size(); i++) {
        byteArray[i] = bytes.get(i);
    }

    // Send the un-escaped string to the COM port
    terminal.txRx.addTxCharsToSend(byteArray);

    if(macro.sendSequenceImmediately.get())
        terminal.txRx.sendBufferedTxDataToSerialPort();

}
 
開發者ID:mbedded-ninja,項目名稱:NinjaTerm,代碼行數:36,代碼來源:MacroManager.java

示例13: ChartUpdater

import org.javatuples.Pair; //導入方法依賴的package包/類
public ChartUpdater(final Pair<Map<String,Object>,Map<String, List<Object>>> results) {
	if (results.getValue0() != null && results.getValue1() != null){
		this.results = new Pair<Map<String,Object>, Map<String,List<Object>>>(new HashMap<String, Object>(results.getValue0()), new HashMap<String, List<Object>>(results.getValue1()));
	} else {
		this.results = new Pair<Map<String,Object>, Map<String,List<Object>>>(null, null);
	}
}
 
開發者ID:crisis-economics,項目名稱:CRISIS,代碼行數:8,代碼來源:Page_Results.java

示例14: write

import org.javatuples.Pair; //導入方法依賴的package包/類
@Override
public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) throws Exception {
    if (msg instanceof Pair) {
        try {
            final Pair pair = (Pair) msg;
            final Iterator itty = (Iterator) pair.getValue1();
            final RequestMessage requestMessage = (RequestMessage) pair.getValue0();

            // the batch size can be overriden by the request
            final int resultIterationBatchSize = (Integer) requestMessage.optionalArgs(Tokens.ARGS_BATCH_SIZE).orElse(settings.resultIterationBatchSize);

            // timer for the total serialization time
            final StopWatch stopWatch = new StopWatch();

            final EventExecutorGroup executorService = ctx.executor();
            final Future<?> iteration = executorService.submit((Callable<Void>) () -> {
                logger.debug("Preparing to iterate results from - {} - in thread [{}]", requestMessage, Thread.currentThread().getName());

                stopWatch.start();

                List<Object> aggregate = new ArrayList<>(resultIterationBatchSize);
                while (itty.hasNext()) {
                    aggregate.add(itty.next());

                    // send back a page of results if batch size is met or if it's the end of the results being
                    // iterated
                    if (aggregate.size() == resultIterationBatchSize || !itty.hasNext()) {
                        final ResponseStatusCode code = itty.hasNext() ? ResponseStatusCode.PARTIAL_CONTENT : ResponseStatusCode.SUCCESS;
                        ctx.writeAndFlush(ResponseMessage.build(requestMessage)
                                .code(code)
                                .result(aggregate).create());
                        aggregate = new ArrayList<>(resultIterationBatchSize);
                    }

                    stopWatch.split();
                    if (stopWatch.getSplitTime() > settings.serializedResponseTimeout)
                        throw new TimeoutException("Serialization of the entire response exceeded the serializeResponseTimeout setting");

                    stopWatch.unsplit();
                }

                return null;
            });

            iteration.addListener(f -> {
                stopWatch.stop();

                if (!f.isSuccess()) {
                    final String errorMessage = String.format("Response iteration and serialization exceeded the configured threshold for request [%s] - %s", msg, f.cause().getMessage());
                    logger.warn(errorMessage);
                    ctx.writeAndFlush(ResponseMessage.build(requestMessage).code(ResponseStatusCode.SERVER_ERROR_TIMEOUT).statusMessage(errorMessage).create());
                }
            });
        } finally {
            ReferenceCountUtil.release(msg);
        }

    } else {
        ctx.write(msg, promise);
    }
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:62,代碼來源:IteratorHandler.java

示例15: shouldHaveSizeOfStarGraphLessThanDetached

import org.javatuples.Pair; //導入方法依賴的package包/類
@Test
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_META_PROPERTIES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_MULTI_PROPERTIES)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY)
public void shouldHaveSizeOfStarGraphLessThanDetached() throws Exception {
    final Random random = new Random(95746498l);
    final Vertex vertex = graph.addVertex("person");
    for (int i = 0; i < 100; i++) { // vertex properties and meta properties
        vertex.property(VertexProperty.Cardinality.list, UUID.randomUUID().toString(), random.nextDouble(),
                "acl", random.nextBoolean() ? "public" : "private",
                "created", random.nextLong());
    }
    for (int i = 0; i < 50000; i++) {  // edges and edge properties
        vertex.addEdge("knows", graph.addVertex("person"), "since", random.nextLong(), "acl", random.nextBoolean() ? "public" : "private");
        graph.addVertex("software").addEdge("createdBy", vertex, "date", random.nextLong());
        graph.addVertex("group").addEdge("hasMember", vertex);
    }
    ///////////////
    Pair<StarGraph, Integer> pair = serializeDeserialize(StarGraph.of(vertex));
    int starGraphSize = pair.getValue1();
    TestHelper.validateEquality(vertex, pair.getValue0().getStarVertex());
    ///
    pair = serializeDeserialize(pair.getValue0());
    assertEquals(starGraphSize, pair.getValue1().intValue());
    starGraphSize = pair.getValue1();
    TestHelper.validateEquality(vertex, pair.getValue0().getStarVertex());
    ///
    pair = serializeDeserialize(pair.getValue0());
    assertEquals(starGraphSize, pair.getValue1().intValue());
    starGraphSize = pair.getValue1();
    TestHelper.validateEquality(vertex, pair.getValue0().getStarVertex());
    ///
    // this is a rough approximation of "detached" serialization of all vertices and edges.
    // now that writeVertex in gryo writes StarGraph that approach can't be used anymore to test
    // serialization size of detached.
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    final GryoWriter writer = graph.io(IoCore.gryo()).writer().create();
    writer.writeObject(outputStream, DetachedFactory.detach(vertex, true));
    vertex.edges(Direction.BOTH).forEachRemaining(e -> writer.writeObject(outputStream, DetachedFactory.detach(e, true)));
    final int detachedVertexSize = outputStream.size();
    assertTrue(starGraphSize < detachedVertexSize);

    logger.info("Size of star graph:        {}", starGraphSize);
    logger.info("Size of detached vertex:   {}", detachedVertexSize);
    logger.info("Size reduction:            {}", (float) detachedVertexSize / (float) starGraphSize);
}
 
開發者ID:PKUSilvester,項目名稱:LiteGraph,代碼行數:50,代碼來源:IoIntegrateTest.java


注:本文中的org.javatuples.Pair.getValue1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。