本文整理汇总了Java中io.vavr.collection.HashSet.of方法的典型用法代码示例。如果您正苦于以下问题:Java HashSet.of方法的具体用法?Java HashSet.of怎么用?Java HashSet.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vavr.collection.HashSet
的用法示例。
在下文中一共展示了HashSet.of方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tailRec
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
public static <T,R> HashSet<R> tailRec(T initial, Function<? super T, ? extends HashSet<? extends io.vavr.control.Either<T, R>>> fn) {
HashSet<io.vavr.control.Either<T, R>> next = HashSet.of(io.vavr.control.Either.left(initial));
boolean newValue[] = {true};
for(;;){
next = next.flatMap(e -> e.fold(s -> {
newValue[0]=true;
return fn.apply(s); },
p -> {
newValue[0]=false;
return HashSet.of(e);
}));
if(!newValue[0])
break;
}
return next.filter(io.vavr.control.Either::isRight).map(io.vavr.control.Either::get);
}
示例2: tailRecEither
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
public static <T,R> HashSet<R> tailRecEither(T initial, Function<? super T, ? extends HashSet<? extends Either<T, R>>> fn) {
HashSet<Either<T, R>> next = HashSet.of(Either.left(initial));
boolean newValue[] = {true};
for(;;){
next = next.flatMap(e -> e.visit(s -> {
newValue[0]=true;
return fn.apply(s); },
p -> {
newValue[0]=false;
return HashSet.of(e);
}));
if(!newValue[0])
break;
}
return next.filter(Either::isRight).map(e->e.orElse(null));
}
示例3: setUp
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// logger.info(logger.getName());
logger.debug(" ===========> debug log");
logger.info(" *** ");
tickers = HashSet.of(Ticker.of("ABC.L"), Ticker.of("DEF.L"));
}
示例4: testHashSet
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSet() throws Exception {
HashSet<A> src = HashSet.of(new B("a", "b"));
String json = MAPPER.writeValueAsString(new HashSetPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":[{\"ExtFieldsPojoTest$B\":{\"a\":\"a\",\"b\":\"b\"}}]}");
HashSetPojo pojo = MAPPER.readValue(json, HashSetPojo.class);
HashSet<A> restored = pojo.getValue();
Assert.assertEquals(restored.filter(e -> e instanceof B).length(), 1);
Assert.assertEquals(restored.head().a, "a");
Assert.assertEquals(((B) restored.head()).b, "b");
}
示例5: testHashSetOfString
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfString() throws Exception {
String src0 = "A";
String src1 = "B";
String src2 = "C";
HashSet<String> src = HashSet.of(src0, src1, src2);
String json = MAPPER.writeValueAsString(new ParameterizedHashSetPojo<>(src));
Assert.assertEquals(json, "{\"value\":[\"A\",\"B\",\"C\"]}");
ParameterizedHashSetPojo<java.lang.String> restored =
MAPPER.readValue(json, new TypeReference<ParameterizedHashSetPojo<java.lang.String>>(){});
Assert.assertEquals(src, restored.getValue());
}
示例6: testHashSetOfTuple
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfTuple() throws Exception {
String src00 = "A";
String src01 = "B";
Tuple2<String, String> src0 = Tuple.of(src00, src01);
HashSet<Tuple2<String, String>> src = HashSet.of(src0);
String json = MAPPER.writeValueAsString(new ParameterizedHashSetPojo<>(src));
Assert.assertEquals(json, "{\"value\":[[\"A\",\"B\"]]}");
ParameterizedHashSetPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>> restored =
MAPPER.readValue(json, new TypeReference<ParameterizedHashSetPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){});
Assert.assertEquals(src, restored.getValue());
}
示例7: testHashSetOfString
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfString() throws Exception {
String src0 = "A";
String src1 = "B";
String src2 = "C";
HashSet<String> src = HashSet.of(src0, src1, src2);
String json = MAPPER.writeValueAsString(new HashSetOfString().setValue(src));
Assert.assertEquals(json, "{\"value\":[\"A\",\"B\",\"C\"]}");
HashSetOfString restored = MAPPER.readValue(json, HashSetOfString.class);
Assert.assertEquals(src, restored.getValue());
}
示例8: testHashSetOfTuple
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfTuple() throws Exception {
String src00 = "A";
String src01 = "B";
Tuple2<String, String> src0 = Tuple.of(src00, src01);
HashSet<Tuple2<String, String>> src = HashSet.of(src0);
String json = MAPPER.writeValueAsString(new HashSetOfTuple().setValue(src));
Assert.assertEquals(json, "{\"value\":[[\"A\",\"B\"]]}");
HashSetOfTuple restored = MAPPER.readValue(json, HashSetOfTuple.class);
Assert.assertEquals(src, restored.getValue());
}
示例9: testHashSet
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSet() throws Exception {
HashSet<I> src = HashSet.of(new B());
String json = MAPPER.writeValueAsString(new HashSetPojo().setValue(src));
Assert.assertEquals(json, "{\"value\":[{\"type\":\"b\"}]}");
HashSetPojo pojo = MAPPER.readValue(json, HashSetPojo.class);
HashSet<I> restored = pojo.getValue();
Assert.assertEquals(restored.filter(e -> e instanceof B).length(), 1);
}
示例10: anySubTag
import io.vavr.collection.HashSet; //导入方法依赖的package包/类
/**
* Matches a tag or (grant)child tag with the given name(s), emitting all tha events that make up that tag and its content.
*/
public static SelectedSubTagProtocol anySubTag(QName... names) {
return new SelectedSubTagProtocol(HashSet.of(names));
}