本文整理汇总了Java中io.vavr.Tuple.of方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.of方法的具体用法?Java Tuple.of怎么用?Java Tuple.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.Tuple
的用法示例。
在下文中一共展示了Tuple.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFactoryAnnotationMetaData
import io.vavr.Tuple; //导入方法依赖的package包/类
private Tuple2<Class<?>, String> getFactoryAnnotationMetaData() {
val constructor = testMethod.getConstructorOrMethod().getConstructor();
val method = testMethod.getConstructorOrMethod().getMethod();
val factoryAnnotation = nonNull(method)
? ofNullable(method.getDeclaredAnnotation(Factory.class))
: ofNullable(constructor.getDeclaredAnnotation(Factory.class));
val dataProviderClass = factoryAnnotation
.map(fa -> (Class) fa.dataProviderClass())
.filter(cl -> cl != Object.class)
.orElseGet(() -> testMethod.getConstructorOrMethod().getDeclaringClass());
val dataProviderMethod = factoryAnnotation.map(Factory::dataProvider).orElse("");
return Tuple.of(dataProviderClass, dataProviderMethod);
}
示例2: testTuple8OfString
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testTuple8OfString() throws Exception {
String src0 = "A";
String src1 = "B";
String src2 = "C";
String src3 = "D";
String src4 = "E";
String src5 = "F";
String src6 = "1";
String src7 = "2";
Tuple8<String, String, String, String, String, String, String, String> src = Tuple.of(src0, src1, src2, src3, src4, src5, src6, src7);
String json = MAPPER.writeValueAsString(new Tuple8OfString().setValue(src));
Assert.assertEquals(json, "{\"value\":[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"1\",\"2\"]}");
Tuple8OfString restored = MAPPER.readValue(json, Tuple8OfString.class);
Assert.assertEquals(src, restored.getValue());
}
示例3: testTuple7OfTuple
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testTuple7OfTuple() throws Exception {
String src0 = "A";
String src10 = "B";
String src11 = "C";
Tuple2<String, String> src1 = Tuple.of(src10, src11);
String src20 = "D";
String src21 = "E";
Tuple2<String, String> src2 = Tuple.of(src20, src21);
String src30 = "F";
String src31 = "1";
Tuple2<String, String> src3 = Tuple.of(src30, src31);
String src4 = "A";
String src50 = "B";
String src51 = "C";
Tuple2<String, String> src5 = Tuple.of(src50, src51);
String src60 = "D";
String src61 = "E";
Tuple2<String, String> src6 = Tuple.of(src60, src61);
Tuple7<String, Tuple2<String, String>, Tuple2<String, String>, Tuple2<String, String>, String, Tuple2<String, String>, Tuple2<String, String>> src = Tuple.of(src0, src1, src2, src3, src4, src5, src6);
String json = MAPPER.writeValueAsString(new Tuple7OfTuple().setValue(src));
Assert.assertEquals(json, "{\"value\":[\"A\",[\"B\",\"C\"],[\"D\",\"E\"],[\"F\",\"1\"],\"A\",[\"B\",\"C\"],[\"D\",\"E\"]]}");
Tuple7OfTuple restored = MAPPER.readValue(json, Tuple7OfTuple.class);
Assert.assertEquals(src, restored.getValue());
}
示例4: testLinkedHashMultimapOfSeqTuple
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testLinkedHashMultimapOfSeqTuple() throws Exception {
String src00 = "A";
String src010 = "A";
String src011 = "B";
Tuple2<String, String> src01 = Tuple.of(src010, src011);
Tuple2<String, Tuple2<String, String>> src0 = Tuple.of(src00, src01);
String src10 = "A";
String src110 = "C";
String src111 = "D";
Tuple2<String, String> src11 = Tuple.of(src110, src111);
Tuple2<String, Tuple2<String, String>> src1 = Tuple.of(src10, src11);
LinkedHashMultimap<String, Tuple2<String, String>> src = LinkedHashMultimap.withSeq().ofEntries(src0, src1);
String json = MAPPER.writeValueAsString(new ParameterizedLinkedHashMultimapPojo<>(src));
Assert.assertEquals(json, "{\"value\":{\"A\":[[\"A\",\"B\"],[\"C\",\"D\"]]}}");
ParameterizedLinkedHashMultimapPojo<java.lang.String, io.vavr.Tuple2<java.lang.String, java.lang.String>> restored =
MAPPER.readValue(json, new TypeReference<ParameterizedLinkedHashMultimapPojo<java.lang.String, io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){});
Assert.assertEquals(src, restored.getValue());
}
示例5: testTuple5OfTuple
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testTuple5OfTuple() throws Exception {
String src0 = "A";
String src10 = "B";
String src11 = "C";
Tuple2<String, String> src1 = Tuple.of(src10, src11);
String src20 = "D";
String src21 = "E";
Tuple2<String, String> src2 = Tuple.of(src20, src21);
String src30 = "F";
String src31 = "1";
Tuple2<String, String> src3 = Tuple.of(src30, src31);
String src4 = "A";
Tuple5<String, Tuple2<String, String>, Tuple2<String, String>, Tuple2<String, String>, String> src = Tuple.of(src0, src1, src2, src3, src4);
String json = MAPPER.writeValueAsString(new Tuple5OfTuple().setValue(src));
Assert.assertEquals(json, "{\"value\":[\"A\",[\"B\",\"C\"],[\"D\",\"E\"],[\"F\",\"1\"],\"A\"]}");
Tuple5OfTuple restored = MAPPER.readValue(json, Tuple5OfTuple.class);
Assert.assertEquals(src, restored.getValue());
}
示例6: testTuple3OfTuple
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testTuple3OfTuple() throws Exception {
String src0 = "A";
String src10 = "B";
String src11 = "C";
Tuple2<String, String> src1 = Tuple.of(src10, src11);
String src20 = "D";
String src21 = "E";
Tuple2<String, String> src2 = Tuple.of(src20, src21);
Tuple3<String, Tuple2<String, String>, Tuple2<String, String>> src = Tuple.of(src0, src1, src2);
String json = MAPPER.writeValueAsString(new ParameterizedTuple3Pojo<>(src));
Assert.assertEquals(json, "{\"value\":[\"A\",[\"B\",\"C\"],[\"D\",\"E\"]]}");
ParameterizedTuple3Pojo<java.lang.String, io.vavr.Tuple2<java.lang.String, java.lang.String>, io.vavr.Tuple2<java.lang.String, java.lang.String>> restored =
MAPPER.readValue(json, new TypeReference<ParameterizedTuple3Pojo<java.lang.String, io.vavr.Tuple2<java.lang.String, java.lang.String>, io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){});
Assert.assertEquals(src, restored.getValue());
}
示例7: processFile
import io.vavr.Tuple; //导入方法依赖的package包/类
private static List<Tuple2<String, String>> processFile(final Vertx vertx, String inputFileStr) {
File file = new File(inputFileStr);
String fileName = inputFileStr.replaceFirst(".*/(\\w+).*","$1");
List<Tuple2<String, String>> rules = new ArrayList<Tuple2<String, String>>();
if (!file.isFile()) {
final List<String> filesList = vertx.fileSystem().readDirBlocking(inputFileStr);
for (final String dirFileStr : filesList) {
List<Tuple2<String, String>> childRules = processFile(vertx, dirFileStr); // use directory name as rulegroup
rules.addAll(childRules);
}
return rules;
} else {
Buffer buf = vertx.fileSystem().readFileBlocking(inputFileStr);
try {
final String ruleText = buf.toString();
Tuple2<String, String> rule = (Tuple.of(fileName, ruleText));
System.out.println("Loading in Rule:" + rule._1 + " of "+ inputFileStr);
rules.add(rule);
return rules;
} catch (final DecodeException dE) {
}
}
return null;
}
示例8: deal
import io.vavr.Tuple; //导入方法依赖的package包/类
public Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count)
{
Set<Card> hand = HashSet.empty();
for (int i = 0; i < count; i++)
{
Tuple2<Card, ? extends List<Card>> cardTuple2 = stack.pop2();
stack = cardTuple2._2();
hand = hand.add(cardTuple2._1());
}
return Tuple.of(hand, stack);
}
示例9: validateCharactersLeft
import io.vavr.Tuple; //导入方法依赖的package包/类
private Tuple2<Color, Integer> validateCharactersLeft(final String currentText) {
final Integer len = currentText.length();
final Color color = Match(len).of(
Case($(tweetLen -> tweetLen < 130), GREEN),
Case($(tweetLen -> tweetLen > 130 && tweetLen < 140), YELLOW),
Case($(tweetLen -> tweetLen > 140), RED),
Case($(tweetLen -> tweetLen == 140), BLUE)
);
return Tuple.of(color, len);
}
示例10: newSession
import io.vavr.Tuple; //导入方法依赖的package包/类
public Tuple2<URL, RequestToken> newSession() {
log.info("Requesting new Session!");
final RequestToken requestToken = unchecked((CheckedFunction0<RequestToken>) this.twitter::getOAuthRequestToken).apply();
log.info("Got request token : {}", requestToken.toString());
return Tuple.of(
unchecked((CheckedFunction0<URL>) (() -> new URL(requestToken.getAuthorizationURL()))).apply(),
requestToken
);
}
示例11: getTestAnnotationMetaData
import io.vavr.Tuple; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Tuple2<Class<?>, String> getTestAnnotationMetaData() {
val declaringClass = testMethod.getConstructorOrMethod().getDeclaringClass();
val testAnnotation = ofNullable(testMethod.getConstructorOrMethod()
.getMethod()
.getDeclaredAnnotation(Test.class))
.orElseGet(() -> declaringClass.getDeclaredAnnotation(Test.class));
val dataSupplierClass = ofNullable(testAnnotation)
.map(Test::dataProviderClass)
.filter(dp -> dp != Object.class)
.orElse((Class) declaringClass);
return Tuple.of(dataSupplierClass, testAnnotation.dataProvider());
}
示例12: fromJsonArray
import io.vavr.Tuple; //导入方法依赖的package包/类
@Override
Tuple fromJsonArray(JsonArray json, Type type, Type[] subTypes, JsonDeserializationContext ctx) {
if (subTypes.length > 0 && json.size() != subTypes.length) {
throw new JsonParseException("elements expected: " + subTypes.length);
}
Object[] arr = new Object[json.size()];
for (int i = 0; i < json.size(); i++) {
JsonElement el = json.get(i);
arr[i] = subTypes.length > 0 ? ctx.deserialize(el, subTypes[i]) : el;
}
switch (json.size()) {
case 0:
return Tuple0.instance();
case 1:
return Tuple.of(arr[0]);
case 2:
return Tuple.of(arr[0], arr[1]);
case 3:
return Tuple.of(arr[0], arr[1], arr[2]);
case 4:
return Tuple.of(arr[0], arr[1], arr[2], arr[3]);
case 5:
return Tuple.of(arr[0], arr[1], arr[2], arr[3], arr[4]);
case 6:
return Tuple.of(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
case 7:
return Tuple.of(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6]);
case 8:
return Tuple.of(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7]);
default:
throw new JsonParseException("bad tuple arity");
}
}
示例13: fromJsonObject
import io.vavr.Tuple; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
T fromJsonObject(JsonObject obj, Type type, Type[] subTypes, JsonDeserializationContext ctx) throws JsonParseException {
Function<java.util.Map.Entry<String, JsonElement>, Tuple2<String, ?>> mapper;
if (subTypes.length == 2) {
mapper = e -> Tuple.of(ctx.deserialize(new JsonPrimitive(e.getKey()), subTypes[0]), ctx.deserialize(e.getValue(), subTypes[1]));
} else {
mapper = e -> Tuple.of(e.getKey(), e.getValue());
}
return (T) factory.apply(obj.entrySet().stream().map(mapper).collect(Collectors.toList()));
}
示例14: compile2
import io.vavr.Tuple; //导入方法依赖的package包/类
/**
* Returns a Regex for a regular expression with 2 capture groups.
*/
public static Regex<Tuple2<String,String>> compile2(String regex, int flags) {
return new Regex<Tuple2<String,String>>(regex, flags) {
@Override
protected Tuple2<String, String> extract(Matcher m) {
return Tuple.of(m.group(1), m.group(2));
}
};
}
示例15: testTuple2OfString
import io.vavr.Tuple; //导入方法依赖的package包/类
@Test
public void testTuple2OfString() throws Exception {
String src0 = "A";
String src1 = "B";
Tuple2<String, String> src = Tuple.of(src0, src1);
String json = MAPPER.writeValueAsString(new Tuple2OfString().setValue(src));
Assert.assertEquals(json, "{\"value\":[\"A\",\"B\"]}");
Tuple2OfString restored = MAPPER.readValue(json, Tuple2OfString.class);
Assert.assertEquals(src, restored.getValue());
}