本文整理汇总了Java中org.javatuples.Triplet类的典型用法代码示例。如果您正苦于以下问题:Java Triplet类的具体用法?Java Triplet怎么用?Java Triplet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Triplet类属于org.javatuples包,在下文中一共展示了Triplet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPitchDirFromVector
import org.javatuples.Triplet; //导入依赖的package包/类
PitchDir getPitchDirFromVector(dVector2 vec) throws RPCException, IOException
{
PitchDir toRet = new PitchDir(0,0);
Triplet<Double, Double, Double> relVel = spaceCenter.transformPosition(booster_flight.getVelocity(), booster.getOrbit().getBody().getReferenceFrame(), booster.getSurfaceReferenceFrame());
align_vel_current.x = ((Double) relVel.getValue1()).doubleValue();
align_vel_current.y = ((Double) relVel.getValue2()).doubleValue();
align_vel_current = align_vel_current.Swap();
vec = vec.Subtract(align_vel_current);
toRet.HDG = (float) ((Math.atan2(vec.x, vec.y)/Math.PI)*180d);
if(toRet.HDG < 0) toRet.HDG = 360f + toRet.HDG;
double length = Math.pow(1+vec.Magnitude(), align_vel_pow)-1;
toRet.pitch = Math.max(align_pitch_min,(float)(90d - length*align_pitch_factor) );
return toRet;
}
示例2: testCreateTupleFromVarArgs
import org.javatuples.Triplet; //导入依赖的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);
}
示例3: downloadFromFileId
import org.javatuples.Triplet; //导入依赖的package包/类
/**
* @return a list of {@literal Triplet<byte[] data, String filename, String fileExtension>}
*/
private Triplet<byte[], String, String> downloadFromFileId(String fileId) throws TelegramApiException, IOException {
GetFile getFile = new GetFile();
getFile.setFileId(fileId);
File file = execute(getFile);
URL fileUrl = new URL(file.getFileUrl(configs.get(TOKEN_KEY)));
HttpURLConnection httpConn = (HttpURLConnection) fileUrl.openConnection();
InputStream inputStream = httpConn.getInputStream();
byte[] output = IOUtils.toByteArray(inputStream);
String fileName = file.getFilePath();
String[] fileNameSplitted = fileName.split("\\.");
String extension = fileNameSplitted[fileNameSplitted.length - 1];
String filenameWithoutExtension = fileName.substring(0, fileName.length() - extension.length() - 1);
inputStream.close();
httpConn.disconnect();
return new Triplet<>(output, filenameWithoutExtension, extension);
}
示例4: onAttachmentReceived
import org.javatuples.Triplet; //导入依赖的package包/类
private void onAttachmentReceived(BotMessage botMsg, Message message,
String fileId, BotDocumentType type,
String msgId) {
try {
Triplet<byte[], String, String> data = downloadFromFileId(fileId);
BotTextMessage textMessage = new BotTextMessage(botMsg, message.getCaption());
BotDocumentMessage documentMessage = new BotDocumentMessage(textMessage,
data.getValue1(), data.getValue2(), data.getValue0(), type);
botsController.sendMessage(documentMessage,
Long.toString(message.getChatId()), Optional.of(msgId));
} catch (TelegramApiException | IOException e) {
logger.error("Error loading the media received. ", e);
}
}
示例5: run
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public void run() throws AGuSDataException {
try {
Node node = krpcVessel.getControl().getNodes().get(0);
AutoPilot autoPilot = krpcVessel.getAutoPilot();
autoPilot.engage();
ReferenceFrame refFrame = krpcVessel.getOrbit().getBody().getReferenceFrame();
Triplet<Double, Double, Double> direction = node.direction(refFrame);
autoPilot.setReferenceFrame(refFrame);
autoPilot.setTargetDirection(direction);
spaceCenter.setPhysicsWarpFactor(maxPhysicsWarp);
autoPilot.wait_();
spaceCenter.setPhysicsWarpFactor(1);
spaceCenter.warpTo(maneuver.getUT() - 120, calcMaxRailsWarpFactor(maneuver.getUT()), maxPhysicsWarp);
autoPilot.disengage();
} catch (RPCException | IOException e) {
e.printStackTrace();
LOGGER.logger.log(Level.SEVERE, "", e);
throw new AGuSDataException(e);
}
}
开发者ID:Nik4053,项目名称:KSP-AGuS-Automatic-Guidance-System,代码行数:23,代码来源:ORIENTATE_AND_WARP_TO_MANEUVER.java
示例6: run
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public void run() throws AGuSDataException {
try {
Node node = krpcVessel.getControl().getNodes().get(0);
AutoPilot autoPilot = krpcVessel.getAutoPilot();
autoPilot.engage();
ReferenceFrame refFrame = krpcVessel.getOrbit().getBody().getReferenceFrame();
Triplet<Double, Double, Double> direction = node.direction(refFrame);
autoPilot.setReferenceFrame(refFrame);
autoPilot.setTargetDirection(direction);
spaceCenter.setPhysicsWarpFactor(maxPhysicsWarp);
autoPilot.wait_();
spaceCenter.setPhysicsWarpFactor(1);
spaceCenter.warpTo(node.getUT() - 120, calcMaxRailsWarpFactor(node.getUT()), maxPhysicsWarp);
autoPilot.disengage();
} catch (RPCException | IOException e) {
e.printStackTrace();
LOGGER.logger.log(Level.SEVERE, "", e);
throw new AGuSDataException(e);
}
}
示例7: asList
import org.javatuples.Triplet; //导入依赖的package包/类
@Test
public void asList() throws Exception {
final Instant now = now();
final RestModel restModel = RestModel.newRestModel();
final List<Triplet<Class<?>, Object, Object>> fixtures = new ArrayList<>();
fixtures.add(new Triplet<>(Boolean.class, Arrays.asList(true), Arrays.asList(true)));
fixtures.add(new Triplet<>(Byte.class, Arrays.asList((byte) 1), Arrays.asList((byte) 1)));
fixtures.add(new Triplet<>(Short.class, Arrays.asList((short) 1), Arrays.asList((short) 1)));
fixtures.add(new Triplet<>(Integer.class, Arrays.asList(1), Arrays.asList(1)));
fixtures.add(new Triplet<>(Long.class, Arrays.asList(1l), Arrays.asList(1l)));
fixtures.add(new Triplet<>(String.class, Arrays.asList("name"), Arrays.asList("name")));
fixtures.add(new Triplet<>(State.class, Arrays.asList("BLOCKED"), Arrays.asList(BLOCKED)));
fixtures.add(new Triplet<>(Instant.class, Arrays.asList(now), Arrays.asList(now)));
fixtures.add(new Triplet<>(RestModel.class, Arrays.asList(restModel), Arrays.asList(restModel)));
for (int i = 0; i < fixtures.size(); i++) {
final Triplet<Class<?>, Object, Object> fixture = fixtures.get(i);
final Class<?> type = fixture.getValue0();
final Object input = fixture.getValue1();
final Object expected = fixture.getValue2();
final List<?> output = new RestValue(input).asListOf(type);
assertEquals(expected, output);
}
}
示例8: getSrgNameMd
import org.javatuples.Triplet; //导入依赖的package包/类
public static Triplet<String, String, String[]> getSrgNameMd(String method) {
Matcher mtch = OWNERNAME.matcher(method);
if (!mtch.find()) {
RMLog.fatal("Method string does not match pattern!", true);
throw new RuntimeException("SRG-Name not found!");
}
String srgName = ASMHelper.isMCP ? null : MAPPINGS.get(method);
String owner = mtch.group(1);
String[] splitMd = mtch.group(2).split(" ");
String name = srgName == null ? splitMd[0] : srgName;
String[] additData = Arrays.copyOfRange(splitMd, 1, splitMd.length);
return Triplet.with(owner, name, additData);
}
示例9: getSrgNameFd
import org.javatuples.Triplet; //导入依赖的package包/类
public static Triplet<String, String, String> getSrgNameFd(String field) {
Matcher mtch = OWNERNAME.matcher(field);
if (!mtch.find()) {
RMLog.fatal("Field string does not match pattern!", true);
throw new RuntimeException("SRG-Name not found!");
}
String srgName = ASMHelper.isMCP ? null : MAPPINGS.get(field);
String owner = mtch.group(1);
String[] splitFd = mtch.group(2).split(" ");
String name = srgName == null ? splitFd[0] : srgName;
String desc = splitFd[1];
return Triplet.with(owner, name, desc);
}
示例10: createGroupCollector
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public GroupCollector<Triplet<R, C, V>, T> createGroupCollector() {
return new GroupCollector<Triplet<R, C, V>, T>() {
private final T table = createTable();
@Override
public void add(Triplet<R, C, V> triplet) {
table.put(triplet.getValue0(), triplet.getValue1(), triplet.getValue2());
}
@Override
public T get() {
return table;
}
};
}
示例11: add
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public void add(Triplet<R, C, V> triplet) {
R row = triplet.getValue0();
GroupCollector<R, R2> rowCollector = rowCollectors.get(row);
if (rowCollector == null) {
rowCollector = rowExpression.createGroupCollector();
rowCollectors.put(row, rowCollector);
}
rowCollector.add(row);
C column = triplet.getValue1();
GroupCollector<C, C2> columnCollector = columnCollectors.get(column);
if (columnCollector == null) {
columnCollector = columnExpression.createGroupCollector();
columnCollectors.put(column, columnCollector);
}
columnCollector.add(column);
GroupCollector<V, V2> valueCollector = valueCollectors.get(rowCollector, columnCollector);
if (valueCollector == null) {
valueCollector = valueExpression.createGroupCollector();
valueCollectors.put(rowCollector, columnCollector, valueCollector);
}
V value = triplet.getValue2();
valueCollector.add(value);
}
示例12: get
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public T get() {
for (Map.Entry<GroupCollector<R, R2>, Map<GroupCollector<C, C2>, GroupCollector<V, V2>>> rowEntry
: valueCollectors.rowMap().entrySet()) {
GroupCollector<R, R2> rowCollector = rowEntry.getKey();
R2 row = rowCollector.get();
Map<GroupCollector<C, C2>, GroupCollector<V, V2>> columnMap = rowEntry.getValue();
for (Map.Entry<GroupCollector<C, C2>, GroupCollector<V, V2>> columnEntry : columnMap.entrySet()) {
GroupCollector<C, C2> columnCollector = columnEntry.getKey();
C2 column = columnCollector.get();
GroupCollector<V, V2> valueCollector = columnEntry.getValue();
V2 value = valueCollector.get();
groupCollector.add(Triplet.with(row, column, value));
}
}
rowCollectors.clear();
columnCollectors.clear();
valueCollectors.clear();
return groupCollector.get();
}
示例13: findRendererNoCache
import org.javatuples.Triplet; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> Renderer<? super T> findRendererNoCache(Class<?> rootType, FieldPath path, Class<T> valueType) {
Renderer<? super T> renderer = (Renderer<? super T>) renderers.get(Triplet.with(rootType, path, valueType));
if (renderer != null) {
return renderer;
}
renderer = (Renderer<? super T>) renderers.get(Triplet.with(rootType, path, null));
if (renderer != null) {
return renderer;
}
renderer = (Renderer<? super T>) renderers.get(Triplet.with(rootType, null, valueType));
if (renderer != null) {
return renderer;
}
renderer = (Renderer<? super T>) renderers.get(Triplet.with(null, null, valueType));
if (renderer != null) {
return renderer;
}
return findDefaultRenderer(valueType);
}
示例14: setParameter1
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public IThreeParameterLinkDescriptorMapper<L, T2, T3, T4> setParameter1(final IModel<T1> model1) {
return new AbstractThreeParameterLinkDescriptorMapper<L, T2, T3, T4>() {
private static final long serialVersionUID = 1L;
@Override
public L map(Triplet<? extends IModel<T2>, ? extends IModel<T3>, ? extends IModel<T4>> param) {
return AbstractFourParameterLinkDescriptorMapper.this.map(param.addAt0(model1));
}
@Override
public void detach() {
super.detach();
model1.detach();
AbstractFourParameterLinkDescriptorMapper.this.detach();
}
};
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:AbstractFourParameterLinkDescriptorMapper.java
示例15: setParameter2
import org.javatuples.Triplet; //导入依赖的package包/类
@Override
public AbstractThreeParameterLinkDescriptorMapper<L, T1, T3, T4> setParameter2(final IModel<T2> model2) {
return new AbstractThreeParameterLinkDescriptorMapper<L, T1, T3, T4>() {
private static final long serialVersionUID = 1L;
@Override
public L map(Triplet<? extends IModel<T1>, ? extends IModel<T3>, ? extends IModel<T4>> param) {
return AbstractFourParameterLinkDescriptorMapper.this.map(param.addAt1(model2));
}
@Override
public void detach() {
super.detach();
model2.detach();
AbstractFourParameterLinkDescriptorMapper.this.detach();
}
};
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:AbstractFourParameterLinkDescriptorMapper.java