当前位置: 首页>>代码示例>>Java>>正文


Java Pair.of方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.tuple.Pair.of方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.of方法的具体用法?Java Pair.of怎么用?Java Pair.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.tuple.Pair的用法示例。


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

示例1: handlePerspective

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	if (baseSpellPageModel instanceof IPerspectiveAwareModel) {
		Matrix4f matrix4f = ((IPerspectiveAwareModel) baseSpellPageModel).handlePerspective(cameraTransformType)
				.getRight();
		return Pair.of(this, matrix4f);
	}
	ItemCameraTransforms itemCameraTransforms = baseSpellPageModel.getItemCameraTransforms();
	ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType);
	TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f);
	Matrix4f mat = null;
	if (tr != null) {
		mat = tr.getMatrix();
	}
	return Pair.of(this, mat);
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:17,代码来源:ModelSpellPage.java

示例2: getModule

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Pair<String, M> getModule(Class<M> clazz)
{
    if (recipe.module == null)
    {
        for (Map.Entry<String, TileEntityModuleSupplier> entry : tileEntity.modules.entrySet())
        {
            if (clazz.isAssignableFrom(entry.getValue().getClass()))
            {
                return Pair.of(entry.getKey(), (M) entry.getValue());
            }
        }
    } else
    {
        return Pair.of(recipe.module, (M) tileEntity.modules.get(recipe.module));
    }

    throw new RuntimeException("No machine module found");
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:20,代码来源:BaseRecipeCategory.java

示例3: testSubmitJobReturnsAResponseContainingTheIDReturnedByTheDAO

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Test
public void testSubmitJobReturnsAResponseContainingTheIDReturnedByTheDAO() throws IOException {
    final JobId jobId = TestHelpers.generateJobId();
    final Pair<JobId, CancelablePromise<FinalizedJob>> managerRet = Pair.of(jobId, new SimpleCancelablePromise<>());
    final JobManagerActions jobManagerActions = mockJobManagerThatReturns(managerRet);
    final ReadonlyJobDAO jobDAO = mock(ReadonlyJobDAO.class);
    final JobSpec jobSpec = generateValidJobSpec();
    final JobSpecConfigurationDAO jobSpecConfigurationDAO = mockJobSpecDAOThatReturns(jobSpec);

    final JobResource jobResource = new JobResource(
            jobManagerActions,
            jobDAO,
            jobSpecConfigurationDAO,
            Constants.DEFAULT_PAGE_SIZE);

    final APIJobCreatedResponse resp =
            jobResource.submitJob(TestHelpers.generateSecureSecurityContext(), generateValidJobRequest());

    assertThat(resp.getId()).isEqualTo(jobId);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:21,代码来源:JobResourceTest.java

示例4: testIntVector

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private static Pair<NullableIntVector, ResultVerifier> testIntVector(final int startIndexInCurrentOutput, final int startIndexInJob) {
  NullableIntVector colIntV = new NullableIntVector("colInt", allocator);
  colIntV.allocateNew(5);
  colIntV.getMutator().set(0, 20);
  colIntV.getMutator().set(1, 50);
  colIntV.getMutator().set(2, -2000);
  colIntV.getMutator().set(3, 327345);
  colIntV.getMutator().setNull(4);

  ResultVerifier verifier = new ResultVerifier() {
    @Override
    public void verify(DataPOJO output) {
      int index = startIndexInCurrentOutput;
      assertEquals(20, ((Integer)output.extractValue("colInt", 0)).intValue());
      assertEquals(50, ((Integer)output.extractValue("colInt", 1)).intValue());
      assertEquals(-2000, ((Integer)output.extractValue("colInt", 2)).intValue());
      assertEquals(327345, ((Integer)output.extractValue("colInt", 3)).intValue());
      assertNull(output.extractValue("colInt", 4));
    }
  };

  return Pair.of(colIntV, verifier);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:TestData.java

示例5: getInventory

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
private Pair<IItemHandler, ISidedInventory> getInventory(EnumFacing facing) {
	BlockPos target = getPos().offset(facing);
	if(world.isBlockLoaded(target, false)) {
		TileEntity tile = world.getTileEntity(target);
		if(tile != null) {
			IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
			if(handler == null) handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
			return Pair.of(handler, tile instanceof ISidedInventory ? (ISidedInventory) tile : null);
		}
	}
	return Pair.of(null, null);
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:13,代码来源:TileVacuumConveyor.java

示例6: handlePerspective

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
{
    if(cameraTransformType == ItemCameraTransforms.TransformType.GUI)
        return Pair.of(this, mat_gui);
    return Pair.of(this, mat);
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:8,代码来源:StandardModels.java

示例7: execute

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<Boolean, byte[]> execute(byte[] data) {

    if (data == null)
        return Pair.of(true, EMPTY_BYTE_ARRAY);

    int baseLen = parseLen(data, 0);
    int expLen  = parseLen(data, 1);
    int modLen  = parseLen(data, 2);

    BigInteger base = parseArg(data, ARGS_OFFSET, baseLen);
    BigInteger exp  = parseArg(data, addSafely(ARGS_OFFSET, baseLen), expLen);
    BigInteger mod  = parseArg(data, addSafely(addSafely(ARGS_OFFSET, baseLen), expLen), modLen);

    // check if modulus is zero
    if (isZero(mod))
        return Pair.of(true, EMPTY_BYTE_ARRAY);

    byte[] res = stripLeadingZeroes(base.modPow(exp, mod).toByteArray());

    // adjust result to the same length as the modulus has
    if (res.length < modLen) {

        byte[] adjRes = new byte[modLen];
        System.arraycopy(res, 0, adjRes, modLen - res.length, res.length);

        return Pair.of(true, adjRes);

    } else {
        return Pair.of(true, res);
    }
}
 
开发者ID:Aptoide,项目名称:AppCoins-ethereumj,代码行数:33,代码来源:PrecompiledContracts.java

示例8: getValues

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
/** Return a pair of ParseGraphs containing the parsed values from each file respectively. */
private static Pair<ParseGraph, ParseGraph> getValues(final File preFile, final File postFile) throws IOException {
    final ParseGraph valuesFromPreDumpFile = getValuesFromDumpFile(preFile);
    final ParseGraph valuesFromPostDumpFile = getValuesFromDumpFile(postFile);

    return Pair.of(valuesFromPreDumpFile, valuesFromPostDumpFile);
}
 
开发者ID:NCSC-NL,项目名称:PEF,代码行数:8,代码来源:CLToolTestUtil.java

示例9: isValid

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
/**
 * 检查请求参数
 * 
 * @param checkApp
 *            是否检查app字段,app字段不是直接根据客户端字段设置的
 * @return <isValid, message>
 */
public Pair<Boolean, String> isValid(boolean checkApp) {
    if (userId == null || userId <= 0) {
        return Pair.of(Boolean.FALSE, "invalid userId");
    }
    if (checkApp && app == null) {
        return Pair.of(Boolean.FALSE, "app is null");
    }
    if (StringUtils.isBlank(branchName)) {
        return Pair.of(Boolean.FALSE, "branchName is null");
    }
    if (StringUtils.isBlank(versionName)) {
        return Pair.of(Boolean.FALSE, "versionName is null");
    }
    if (CollectionUtils.isEmpty(channelIdList)) {
        return Pair.of(Boolean.FALSE, "channelIdList is empty");
    }
    for (Integer channelId : channelIdList) {
        if (channelId == null || channelId <= 0) {
            return Pair.of(Boolean.FALSE, "invalid channelId:" + channelId);
        }
    }
    if (CollectionUtils.isEmpty(mailReceiverIdList)) {
        return Pair.of(Boolean.FALSE, "mailReceiverIdList is empty");
    }
    for (Integer mailReceiverId : mailReceiverIdList) {
        if (mailReceiverId == null || mailReceiverId <= 0) {
            return Pair.of(Boolean.FALSE, "invalid mailReceiverId:"
                    + mailReceiverId);
        }
    }
    return Pair.of(Boolean.TRUE, "valid");
}
 
开发者ID:wittyLuzhishen,项目名称:EasyPackage,代码行数:40,代码来源:TaskParam.java

示例10: provideVolume

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<Byte, Byte> provideVolume(ItemStack item)
{
	switch (item.getMetadata())
	{
		case 0:
		{
			return Pair.of((byte)3, (byte)2);
		}
		
		case 1:
		case 2:
		{
			return Pair.of((byte)2, (byte)2);
		}
		
		case 3:
		case 4:
		{
			return Pair.of((byte)1, (byte)2);
		}
		
		default:
		{
			return PlayerInventoryHelper.defaultVolume;
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:29,代码来源:ItemToolHead.java

示例11: handlePerspective

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {

	// if (transformMap.containsValue(cameraTransformType))
	// return Pair.of(this,
	// transformMap.get(cameraTransformType).getMatrix());

	if (applyTransfomation(cameraTransformType) != null)
		return Pair.of(this, applyTransfomation(cameraTransformType).getMatrix());

	return MapWrapper.handlePerspective(this, MapWrapper.getTransforms(getItemCameraTransforms()), cameraTransformType);
}
 
开发者ID:oMilkyy,项目名称:SimpleTubes,代码行数:13,代码来源:AbstractPerspective.java

示例12: create

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
public JMethod create(final ReturnTypeInfo info, final Pair<String, String> pathPrefix, final Map<Pair<String, String>, RestOperation> docs,
    final ParentInvocation... parentInvocations) {

  this.returnType = info.getRawType();

  // determine method name and return type
  Optional<TypeStep> dto = Optional.empty();
  if (info.isParametrized()) {
    this.methodReturnType = this.clazz.owner().ref(info.getRawType()).narrow(info.getParameterTypes());
    if (TypeHelper.isList(info.getRawType())) {
      this.returnTypeStyle = ReturnTypeStyle.DTO_LIST;
    } else if (TypeHelper.isMap(info.getRawType()) // map
        && info.getParameterTypes().length == 2 // parametrized
        && TypeHelper.isString(info.getParameterTypes()[0])) { // with string as key
      this.returnTypeStyle = ReturnTypeStyle.DTO_MAP_STRING;
    } else {
      // doesn't support return parametrized type
      log.debug("Unsupported return collection type with {} type parameters:", info.getParameterTypes().length, info.getRawType().getName());
      this.returnTypeStyle = ReturnTypeStyle.PLAIN;
    }
  } else {
    dto = Optional.of(new TypeStep(modelRepository, info.getRawType(), clazz.owner()));
    this.returnTypeStyle = dto.get().isDto() ? ReturnTypeStyle.DTO : ReturnTypeStyle.PLAIN;
    this.methodReturnType = dto.get().getType();
  }

  final String methodName = methodName(parentInvocations, info.getMethod().getName());
  method = clazz.method(JMod.PUBLIC, methodReturnType, methodName);

  // path annotation
  final PathAnnotationStep pathAnnotationStep = new PathAnnotationStep(this);
  pathAnnotationStep.annotate(pathPrefix.getRight(), info.getMethod());
  this.path = pathAnnotationStep.getPath();

  // JAX RS
  final JaxRsAnnotationStep jaxrsAnnotation = new JaxRsAnnotationStep(method);
  jaxrsAnnotation.annotate(info.getMethod());

  // consume and produce
  final ConsumesAndProducesStep consumesAndProduces = new ConsumesAndProducesStep(method);
  consumesAndProduces.annotate(info.getMethod());

  final Pair key = Pair.of(DocumentationYaml.normalizePath(pathPrefix.getLeft() + this.path), jaxrsAnnotation.getType().getSimpleName());
  final RestOperation doc = docs.get(key);
  if (doc == null) {
    log.error("No doc found for {}", key);
  }

  // register docs for this DTO.
  if (dto.isPresent()) {
    modelRepository.addDoc(dto.get().getFullQualifiedName(), doc, DocStyle.RETURN_TYPE);
  }

  // create invocation
  final JInvocation invoke = new InvocationStep(method).method(modelRepository, info.getMethod(), doc, parentInvocations);

  // body
  if (TypeHelper.isVoid(getReturnType())) {
    method.body().add(invoke);
  } else {

    // overriding, only if it is a simple return type (not parametrized, not DTO, not a resource)
    if (parentInvocations == null) {
      method.annotate(Override.class);
    }

    method.body()._return(invoke);
  }

  // ApiOperation
  final ApiOperationStep apiOperation = new ApiOperationStep(method, doc);
  apiOperation.annotate(this, info.getMethod());
  // add method
  restService.getOperations().put(info.getMethod().getName(), doc);

  // ApiResponse
  final ApiResponsesStep responesStep = new ApiResponsesStep(method, doc);
  responesStep.annotate(this, info.getMethod());

  return method;
}
 
开发者ID:camunda,项目名称:camunda-bpm-swagger,代码行数:82,代码来源:MethodStep.java

示例13: parseAttributeTypeAggregator

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
/**
 * Parses BGP UPDATE Attribute Type AGGREGATOR.
 *
 * @param bgpSession the BGP Session to use
 * @param ctx the Channel Handler Context
 * @param attrTypeCode the attribute type code
 * @param attrLen the attribute length (in octets)
 * @param attrFlags the attribute flags
 * @param message the message to parse
 * @return the parsed AGGREGATOR value: a tuple of <AS-Number, IP-Address>
 * @throws BgpMessage.BgpParseException
 */
private static Pair<Long, Ip4Address> parseAttributeTypeAggregator(
                                            BgpSession bgpSession,
                                            ChannelHandlerContext ctx,
                                            int attrTypeCode,
                                            int attrLen,
                                            int attrFlags,
                                            ChannelBuffer message)
    throws BgpMessage.BgpParseException {
    int expectedAttrLen;

    if (bgpSession.isAs4OctetCapable()) {
        expectedAttrLen = BgpConstants.Update.Aggregator.AS4_LENGTH;
    } else {
        expectedAttrLen = BgpConstants.Update.Aggregator.AS2_LENGTH;
    }

    // Check the Attribute Length
    if (attrLen != expectedAttrLen) {
        // ERROR: Attribute Length Error
        actionsBgpUpdateAttributeLengthError(
            bgpSession, ctx, attrTypeCode, attrLen, attrFlags, message);
        String errorMsg = "Attribute Length Error";
        throw new BgpMessage.BgpParseException(errorMsg);
    }

    // The AGGREGATOR AS number
    long aggregatorAsNumber;
    if (bgpSession.isAs4OctetCapable()) {
        aggregatorAsNumber = message.readUnsignedInt();
    } else {
        aggregatorAsNumber = message.readUnsignedShort();
    }
    // The AGGREGATOR IP address
    Ip4Address aggregatorIpAddress =
        Ip4Address.valueOf((int) message.readUnsignedInt());

    Pair<Long, Ip4Address> aggregator = Pair.of(aggregatorAsNumber,
                                                aggregatorIpAddress);
    return aggregator;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:53,代码来源:BgpUpdate.java

示例14: provideVolume

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@Override
public Pair<Byte, Byte> provideVolume(ItemStack item)
{
	return Pair.of((byte)2, (byte)2);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:6,代码来源:BlockStone.java

示例15: findFirstAvailableSlotFor

import org.apache.commons.lang3.tuple.Pair; //导入方法依赖的package包/类
@SuppressWarnings("SuspiciousNameCombination")
   public static int findFirstAvailableSlotFor(ItemStack is, Optional<Map<Pair<Integer, Integer>, Boolean>> data, EntityPlayer player)
{
	InventoryPlayer inventory = player.inventory;
	for (int i = 0; i < inventory.getSizeInventory(); ++i)
	{
		ItemStack stack = player.inventory.getStackInSlot(i);
		if (ItemStack.areItemsEqual(stack, is) && ItemStack.areItemStackTagsEqual(stack, is))
		{
			int max = Math.min(player.openContainer != null ? player.openContainer.getSlot(i).getItemStackLimit(stack) : inventory.getInventoryStackLimit(), stack.getMaxStackSize());
			if (stack.getCount() < max)
			{
				return Short.MAX_VALUE + i;
			}
		}
	}
	
	for (int i = 0; i < 9; ++i)
	{
		if (inventory.getStackInSlot(i).isEmpty())
		{
			return i;
		}
	}
	
	Map<Pair<Integer, Integer>, Boolean> lookup = data.orElseGet(() -> PlayerInventoryHelper.getSlotData(player));
	Pair<Byte, Byte> volume = getVolume(is);
	slotLoop: for (int i = 9; i < 36; ++i)
	{
		int x = (i - 9) % 9;
		int y = (i - 9) / 9;
		if (x + volume.getLeft() > 9 || y + volume.getRight() > 3)
		{
			continue;
		}
		
		Pair<Integer, Integer> pos = Pair.of(x, y);
		if (lookup.containsKey(pos) && lookup.get(pos))
		{
			continue;
		}
		
		for (int dx = x; dx < x + volume.getLeft(); ++dx)
		{
			for (int dy = y; dy < y + volume.getRight(); ++dy)
			{
				pos = Pair.of(dx, dy);
				if (dx >= 9 || dy >= 3 || (lookup.containsKey(pos) && lookup.get(pos)))
				{
				    continue slotLoop;
				}
			}
		}
		
		return i;
	}
	
	return -1;
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:60,代码来源:PlayerInventoryHelper.java


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