• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Tuple类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.javatuples.Tuple的典型用法代码示例。如果您正苦于以下问题:Java Tuple类的具体用法?Java Tuple怎么用?Java Tuple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Tuple类属于org.javatuples包,在下文中一共展示了Tuple类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCreateTupleFromVarArgs

import org.javatuples.Tuple; //导入依赖的package包/类
@Test
public void testCreateTupleFromVarArgs() {

    Pair<Integer, String> pair = Tuples.create(10, "foo");
    Assertions.assertThat((Iterable<?>) pair)
            .isEqualTo(new Pair<>(10, "foo"));

    Tuple tuple = Tuples.create(String.class, Long.class);
    Assertions.assertThat((Iterable<?>) tuple)
            .isInstanceOf(Pair.class);
    Assertions.assertThat(tuple.containsAll(String.class, Long.class))
            .isTrue();
    Assertions.assertThat(tuple.getSize())
            .isEqualTo(2);

    tuple = Tuples.create(String.class, Long.class, Float.class);
    Assertions.assertThat((Iterable<?>) tuple)
            .isInstanceOf(Triplet.class);
}
 
开发者ID:seedstack,项目名称:business,代码行数:20,代码来源:TuplesTest.java


示例2: fromConditionFactory

import org.javatuples.Tuple; //导入依赖的package包/类
public static <T extends Tuple> ILinkParameterValidatorFactory<T> fromConditionFactory(
		final IDetachableFactory<T, ? extends Condition> conditionFactory) {
	Args.notNull(conditionFactory, "conditionFactory");
	return new AbstractLinkParameterValidatorFactory<T>() {
		private static final long serialVersionUID = 1L;
		@Override
		public ILinkParameterValidator create(T parameters) {
			return new ConditionLinkParameterValidator(conditionFactory.create(parameters));
		}
		@Override
		public void detach() {
			super.detach();
			conditionFactory.detach();
		}
	};
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:ConditionLinkParameterValidator.java


示例3: createLinkDescriptor

import org.javatuples.Tuple; //导入依赖的package包/类
private <TTarget, TLinkDescriptor> TLinkDescriptor createLinkDescriptor(
		IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
		IModel<? extends TTarget> targetModel) {
	return mapperLinkDescriptorFactory(
			linkDescriptorFactory,
			ModelFactories.<IModel<? extends TTarget>, Tuple>constant(targetModel),
			ImmutableList.<Integer>of()
			)
			.create(new Tuple() {
				private static final long serialVersionUID = 1L;
				@Override
				public int getSize() {
					return 0;
				}
			});
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:NoMappableParameterMainStateImpl.java


示例4: formatTuple

import org.javatuples.Tuple; //导入依赖的package包/类
private String formatTuple(Tuple tuple) {
    StringBuffer buf = new StringBuffer();
    int size = tuple.getSize();
    for (int i = 0; i < size; i ++) {
        if (i != 0) {
            buf.append(';');
        }

        Object obj = tuple.getValue(i);
        if (obj instanceof Tuple) {
            buf.append(formatTuple((Tuple)obj));
        } else {
            buf.append(tuple.getValue(i));
        }
    }
    return buf.toString();
}
 
开发者ID:daqcri,项目名称:Qnoise,代码行数:18,代码来源:NoiseReport.java


示例5: execute

import org.javatuples.Tuple; //导入依赖的package包/类
/**
 * Execute this marvelous code, going from the Content to Users.
 *
 * Internally uses the RecommendationForNewUser class to build the recommendation as we want, pretty and
 * simple.
 *
 * @param vertex
 * @param messenger
 * @param memory
 */
@Override
public void execute(Vertex vertex, Messenger<Tuple> messenger, Memory memory) {
  try {
    HadoopQueryRunner runner = new HadoopQueryRunner(g, vertex.value(Schema.USER_NAME));
    GraphTraversal<Vertex, Edge> t = g.V(vertex.id()).inE(Schema.FOLLOWS);

    while(t.hasNext()) {
      Edge followsEdge = t.next();

      long commonFollowedUsers = runner.countCommonFollowedUsers(followsEdge.outVertex());
      long postsPerDaySince = runner.countPostsPerDaySince(sevenDaysAgo);
      long weight = (3 * commonFollowedUsers + postsPerDaySince) / 4;
      if(min == -10 || min > weight) {
        min = (int) weight;
      }
      if(max < weight) {
        max = (int) weight;
      }
      count++;

      followsEdge.property(CreateWeightIndex.WEIGHT, weight);
    }
  } catch (Exception e){
    e.printStackTrace();
    LOGGER.error("while processing " + vertex.id() + ": " + e.getClass().toString() + "(" + e.getMessage() + ")");
    return;
  }
}
 
开发者ID:marcelocf,项目名称:janusgraph_tutorial,代码行数:39,代码来源:ComputeWeightVertexProgram.java


示例6: clone

import org.javatuples.Tuple; //导入依赖的package包/类
@SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException", "CloneDoesntCallSuperClone"})
public VertexProgram<Tuple> clone() {
  LOGGER.info("clone");
  try {
    return (ComputeWeightVertexProgram) super.clone();
  } catch (final CloneNotSupportedException e) {
    throw new IllegalStateException(e.getMessage(), e);
  }
}
 
开发者ID:marcelocf,项目名称:janusgraph_tutorial,代码行数:10,代码来源:ComputeWeightVertexProgram.java


示例7: HBaseVertex

import org.javatuples.Tuple; //导入依赖的package包/类
public HBaseVertex(HBaseGraph graph, Object id, String label, Long createdAt, Long updatedAt,
                   Map<String, Object> properties, boolean propertiesFullyLoaded) {
    super(graph, id, label, createdAt, updatedAt, properties, propertiesFullyLoaded);

    if (graph != null) {
        this.edgeCache = CacheBuilder.<Tuple, List<Edge>>newBuilder()
                .maximumSize(graph.configuration().getRelationshipCacheMaxSize())
                .expireAfterAccess(graph.configuration().getRelationshipCacheTtlSecs(), TimeUnit.SECONDS)
                .build();
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:12,代码来源:HBaseVertex.java


示例8: execute

import org.javatuples.Tuple; //导入依赖的package包/类
@Override
public void execute(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
    try {
        executeInternal(sourceVertex, messenger, memory);
    } catch (Exception e) {
        if (graph.features().graph().supportsTransactions()) {
            graph.tx().rollback();
        }
        throw e;
    }
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:BulkLoaderVertexProgram.java


示例9:

import org.javatuples.Tuple; //导入依赖的package包/类
private <TTarget, TLinkDescriptor> ITwoParameterLinkDescriptorMapper<TLinkDescriptor, TParam1, TParam2>
		createMapper(IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
				IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>> pageClassFactory,
				List<Integer> parameterIndices) {
	return new CoreTwoParameterLinkDescriptorMapperImpl<>(
			mapperLinkDescriptorFactory(
					linkDescriptorFactory,
					pageClassFactory, parameterIndices
			)
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:TwoMappableParameterMainStateImpl.java


示例10: createMapper

import org.javatuples.Tuple; //导入依赖的package包/类
private <TTarget, TLinkDescriptor> IFourParameterLinkDescriptorMapper<
		TLinkDescriptor,
		TParam1, TParam2, TParam3, TParam4
		> createMapper(IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
				IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>> pageClassFactory,
				List<Integer> parameterIndices) {
	return new CoreFourParameterLinkDescriptorMapperImpl<>(
			mapperLinkDescriptorFactory(
					linkDescriptorFactory,
					pageClassFactory, parameterIndices
			)
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:14,代码来源:FourMappableParameterMainStateImpl.java


示例11:

import org.javatuples.Tuple; //导入依赖的package包/类
private <TTarget, TLinkDescriptor> IThreeParameterLinkDescriptorMapper<TLinkDescriptor, TParam1, TParam2, TParam3>
		createMapper(IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
				IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>> pageClassFactory,
				List<Integer> parameterIndices) {
	return new CoreThreeParameterLinkDescriptorMapperImpl<>(
			mapperLinkDescriptorFactory(
					linkDescriptorFactory,
					pageClassFactory, parameterIndices
			)
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:ThreeMappableParameterMainStateImpl.java


示例12:

import org.javatuples.Tuple; //导入依赖的package包/类
private <TTarget, TLinkDescriptor> IOneParameterLinkDescriptorMapper<TLinkDescriptor, TParam1>
		createMapper(IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
				IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>> pageClassFactory,
				List<Integer> parameterIndices) {
	return new CoreOneParameterLinkDescriptorMapperImpl<>(
			mapperLinkDescriptorFactory(
					linkDescriptorFactory, 
					pageClassFactory, parameterIndices 
			)
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:OneMappableParameterMainStateImpl.java


示例13:

import org.javatuples.Tuple; //导入依赖的package包/类
protected final <TTarget, TLinkDescriptor> IBuilderMapperLinkDescriptorFactory<TLinkDescriptor>
		mapperLinkDescriptorFactory(
				IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
				IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>> targetFactory,
				List<Integer> targetFactoryParameterIndices
		) {
	return linkDescriptorFactory.forMapper(
			Pair.with(targetFactory, targetFactoryParameterIndices),
			mappingEntryBuilders, validatorFactories
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:AbstractMainStateImpl.java


示例14: BuilderMapperLinkDescriptorFactory

import org.javatuples.Tuple; //导入依赖的package包/类
public BuilderMapperLinkDescriptorFactory(
		IBuilderLinkDescriptorFactory<TTarget, TLinkDescriptor> linkDescriptorFactory,
		Pair<
				? extends IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>>,
				? extends List<Integer>
				> targetFactory,
		Map<LinkParameterMappingEntryBuilder<?>, List<Integer>> mappingEntryBuilders,
		Map<ILinkParameterValidatorFactory<?>, List<Integer>> validatorFactories) {
	super();
	this.linkDescriptorFactory = linkDescriptorFactory;
	this.targetFactory = targetFactory;
	this.mappingEntryBuilders = mappingEntryBuilders;
	this.validatorFactories = validatorFactories;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:15,代码来源:BuilderMapperLinkDescriptorFactory.java


示例15: extractParameters

import org.javatuples.Tuple; //导入依赖的package包/类
private static Tuple extractParameters(Tuple parameters, List<Integer> indices) {
	int size = indices.size();
	switch (size) {
	case 0:
		return null;
	case 1:
		return Unit.with(parameters.getValue(indices.get(0)));
	case 2:
		return Pair.with(
				parameters.getValue(indices.get(0)),
				parameters.getValue(indices.get(1))
		);
	case 3:
		return Triplet.with(
				parameters.getValue(indices.get(0)),
				parameters.getValue(indices.get(1)),
				parameters.getValue(indices.get(2))
		);
	case 4:
		return Quartet.with(
				parameters.getValue(indices.get(0)),
				parameters.getValue(indices.get(1)),
				parameters.getValue(indices.get(2)),
				parameters.getValue(indices.get(3))
		);
	default:
		throw new IllegalStateException("Only Unit, Pair, Triplet and Quartet parameters are supported for ILinkParameterMappingEntryFactory");
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:30,代码来源:BuilderMapperLinkDescriptorFactory.java


示例16: forMapper

import org.javatuples.Tuple; //导入依赖的package包/类
IBuilderMapperLinkDescriptorFactory<TLinkDescriptor> forMapper(
		Pair<
				? extends IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>>,
				? extends List<Integer>
				> targetFactory,
		Map<LinkParameterMappingEntryBuilder<?>, List<Integer>> mappingEntryBuilders,
		Map<ILinkParameterValidatorFactory<?>, List<Integer>> validatorFactories
);
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:9,代码来源:IBuilderLinkDescriptorFactory.java


示例17: forMapper

import org.javatuples.Tuple; //导入依赖的package包/类
@Override
public IBuilderMapperLinkDescriptorFactory<TLinkDescriptor> forMapper(
		Pair<
				? extends IDetachableFactory<? extends Tuple, ? extends IModel<? extends TTarget>>,
				? extends List<Integer>
				> targetFactory,
		Map<LinkParameterMappingEntryBuilder<?>, List<Integer>> mappingEntryBuilders,
		Map<ILinkParameterValidatorFactory<?>, List<Integer>> validatorFactories) {
	return new BuilderMapperLinkDescriptorFactory<>(
			this, targetFactory, mappingEntryBuilders, validatorFactories
	);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:13,代码来源:BuilderLinkDescriptorFactory.java


示例18: serializeAndDeserialize

import org.javatuples.Tuple; //导入依赖的package包/类
protected static <T extends Tuple> T serializeAndDeserialize(T tuple) {
	for (Object value : tuple) {
		if (value instanceof IDetachable) {
			((IDetachable)value).detach();
		}
	}
	return doSerializeAndDeserialize(tuple);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:9,代码来源:AbstractWicketMoreTestCase.java


示例19: tupleAssemblerOf

import org.javatuples.Tuple; //导入依赖的package包/类
<T extends Tuple, D> Assembler<T, D> tupleAssemblerOf(Class<? extends AggregateRoot<?>>[] aggregateRootTuple,
        Class<D> dto) {
    if (assemblerQualifierClass != null) {
        return assemblerRegistry.getTupleAssembler(aggregateRootTuple, dto, assemblerQualifierClass);
    } else if (assemblerQualifier != null) {
        return assemblerRegistry.getTupleAssembler(aggregateRootTuple, dto, assemblerQualifier);
    }
    return assemblerRegistry.getTupleAssembler(aggregateRootTuple, dto);
}
 
开发者ID:seedstack,项目名称:business,代码行数:10,代码来源:Context.java


示例20: create

import org.javatuples.Tuple; //导入依赖的package包/类
/**
 * Builds a tuple from a collection of objects.
 *
 * @param objects the collection of objects (size must be less or equal than 10).
 * @param <T>     the tuple type.
 * @return the constructed tuple.
 */
@SuppressWarnings("unchecked")
public static <T extends Tuple> T create(Collection<?> objects) {
    Class<? extends Tuple> tupleClass = classOfTuple(objects.size());
    try {
        return (T) tupleClass.getMethod("fromCollection", Collection.class)
                .invoke(null, objects);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
        throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_CREATE_TUPLE);
    }
}
 
开发者ID:seedstack,项目名称:business,代码行数:18,代码来源:Tuples.java



注:本文中的org.javatuples.Tuple类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NodeExpandEvent类代码示例发布时间:2022-05-23
下一篇:
Java UsbEndpoint类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap