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


Java Seq类代码示例

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


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

示例1: parse

import io.vavr.collection.Seq; //导入依赖的package包/类
static Validation<String, MonthSpec> parse(String cronSpec) {
    Function1<Integer, Validation<String, Month>> parseMonth = item ->
        Try.of(() -> Month.of(item))
        .toValidation(String.format("Invalid month: %d", item));
    return SpecItemParser.parseSpecItem(cronSpec.toLowerCase(), 12, monthMap)
        .flatMap(intSet -> Vavr.sequenceS(intSet.map(parseMonth)))
        .map(Seq::toSet)
        .flatMap(MonthSpec::build);
}
 
开发者ID:emmanueltouzery,项目名称:crony,代码行数:10,代码来源:MonthSpec.java

示例2: writer

import io.vavr.collection.Seq; //导入依赖的package包/类
@Override
public Writer<CsvEvent, String> writer() {
    return new Writer<CsvEvent, String>() {
        @Override
        public Seq<CsvEvent> apply(String value) {
            if (value.isEmpty()) {
                return Vector.empty();
            } else {
                return Vector.of(CsvEvent.text(value));
            }
        }

        @Override
        public Seq<CsvEvent> reset() {
            return Vector.empty();
        }
    };
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:19,代码来源:ValueProtocol.java

示例3: writer

import io.vavr.collection.Seq; //导入依赖的package包/类
@Override
public Writer<CsvEvent, T> writer() {
    Writer<CsvEvent, T> innerWriter = inner.writer();
    
    return new Writer<CsvEvent, T>() {
        boolean first = true;
        
        @Override
        public Seq<CsvEvent> apply(T value) {
            Seq<CsvEvent> events =
                (first) ? Vector.of(CsvEvent.text(name), CsvEvent.endValue(), CsvEvent.endRecord()) : Vector.empty();
            first = false;
            return events.appendAll(innerWriter.apply(value)).append(CsvEvent.endValue()).append(CsvEvent.endRecord());
        }

        @Override
        public Seq<CsvEvent> reset() {
            if (first) {
                first = false;
                return Vector.of(CsvEvent.text(name), CsvEvent.endValue(), CsvEvent.endRecord());
            } else {
                return Vector.empty();
            }
        }
    };
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:27,代码来源:NamedColumnWriteProtocol.java

示例4: readWrite

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Returns a Protocol that uses an AlternativesProtocol for reading, and always picks the first alternative when writing.
 */
public static <E,T> Protocol<E,T> readWrite(Seq<Protocol<E,T>> alternatives) {
    Protocol<E,T> write = alternatives.head();
    AnyOfProtocol<E,T> read = new AnyOfProtocol<>(Seq.narrow(alternatives));
    return new Protocol<E,T>() {
        @Override
        public Writer<E,T> writer() {
            return write.writer();
        }

        @Override
        public Class<? extends E> getEventType() {
            return write.getEventType();
        }

        @Override
        public Reader<E,T> reader() {
            return read.reader();
        }
    };
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:24,代码来源:AnyOfProtocol.java

示例5: set

import io.vavr.collection.Seq; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void set(Consumer<Object> dispatcher, Object node, String name, VProperty vProperty) {
    if (! (node instanceof Node)) {
        throw new IllegalStateException("Unable to read value of property styleClass from class " + node.getClass());
    }

    if (vProperty.isValueDefined()) {
        final ObservableList<String> styleClasses = ((Node) node).getStyleClass();
        styleClasses.retainAll(node.getClass().getSimpleName().toLowerCase());

        if (vProperty.getValue() != null) {
            styleClasses.addAll(((Seq) vProperty.getValue()).toJavaList());
        }
    }
}
 
开发者ID:netopyr,项目名称:reduxfx,代码行数:17,代码来源:StyleClassAccessor.java

示例6: create

import io.vavr.collection.Seq; //导入依赖的package包/类
@Override
Seq<?> create(List<Object> result, DeserializationContext ctxt) throws JsonMappingException {
    if (Array.class.isAssignableFrom(javaType.getRawClass())) {
        return Array.ofAll(result);
    }
    if (Queue.class.isAssignableFrom(javaType.getRawClass())) {
        return Queue.ofAll(result);
    }
    if (Stream.class.isAssignableFrom(javaType.getRawClass())) {
        return Stream.ofAll(result);
    }
    if (Vector.class.isAssignableFrom(javaType.getRawClass())) {
        return Vector.ofAll(result);
    }
    // default deserialization [...] -> Seq
    return io.vavr.collection.List.ofAll(result);
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:18,代码来源:SeqDeserializer.java

示例7: toDataTable

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Return a new DataTable based on this table (clone).
 *
 * @return Returns a new DataTable based on the columns and data in this view.
 */
@Override
public DataTable toDataTable() {
    // Get the list of row indexes used in this data view.
    Seq<Integer> rowIndexes = this.rows.map(DataRow::rowIdx);

    // Build a set of new columns with just the data at the specified indexes.
    return this.table.columns()
            .map(col -> col.buildFromRows(rowIndexes).get())
            .collect(transform(cols -> DataTable.build(this.name(), cols).get()));
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:16,代码来源:DataView.java

示例8: validateSortColumnIdentity

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Validates that all the columns specified in the collection of items
 * to sort are actually contained and identifiable in the DataTable.
 *
 * @param table The table to sort.
 * @param sortItems The collection of sort items.
 * @return Returns validation as a Try.
 */
private static Try<Seq<IDataColumn>> validateSortColumnIdentity(DataTable table, Seq<SortItem> sortItems) {

    // Validate we can get the column for all sort items.
    Seq<Try<IDataColumn>> checkCols = sortItems.map(item -> item.getColumn(table));

    // Any failures, return error else return columns.
    return checkCols.find(Try::isFailure).isEmpty()
            ? Try.success(checkCols.map(Try::get))
            : DataTableException.tryError("Column for Sort Item not found.");
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:19,代码来源:DataSort.java

示例9: validateColumnsAreComparable

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Validates that all the columns being sorted are comparable.
 *
 * @param columns The columns to sort.
 * @return Returns the result as a Try : Success / Failure.
 */
private static Try<Void> validateColumnsAreComparable(Seq<IDataColumn> columns) {
    Option<IDataColumn> invalidCol = columns.find(col -> !col.IsComparable());

    return invalidCol.isEmpty()
            ? Try.success(null)
            : DataTableException.tryError("Column '" + invalidCol.get().name() + "' doesn't support comparable.");
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:14,代码来源:DataSort.java

示例10: compareBySortItem

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Recursive sort method, handles multi-sort on columns.
 *
 * @param rowOne The first row to compare.
 * @param rowTwo The second row to compare.
 * @param sortItems The collection of Sort Item details.
 * @return Returns a single integer for the sort.
 */
private static int compareBySortItem(DataRow rowOne, DataRow rowTwo, Seq<SortItem> sortItems) {

    // No more items to sort, then return 0;
    if (sortItems.isEmpty()) return 0;

    // Compare the values in the two rows for the current sort item.
    Integer compareResult = compareValues(rowOne, rowTwo, sortItems.head());

    // If it's the same, then compare again on the next item until finished.
    return compareResult == 0
            ? compareBySortItem(rowOne, rowTwo, sortItems.tail())
            : compareResult;
}
 
开发者ID:martincooper,项目名称:java-datatable,代码行数:22,代码来源:DataRowComparator.java

示例11: parse

import io.vavr.collection.Seq; //导入依赖的package包/类
static Validation<String, DayOfWeekSpec> parse(String cronSpec) {
    Function1<Integer, Validation<String, DayOfWeek>> parseDow = item ->
        Try.of(() -> item == 0 ? DayOfWeek.SUNDAY : DayOfWeek.of(item))
        .toValidation(String.format("Invalid day of week: %d", item));
    return SpecItemParser.parseSpecItem(cronSpec.toLowerCase(), 7, dayMap)
        .flatMap(intSet -> Vavr.sequenceS(intSet.map(parseDow)))
        .map(Seq::toSet)
        .flatMap(DayOfWeekSpec::build);
}
 
开发者ID:emmanueltouzery,项目名称:crony,代码行数:10,代码来源:DayOfWeekSpec.java

示例12: handleCommand

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Executes the given command using the given handler, emitting any events, and responding to sender().
 */
protected void handleCommand(C cmd, AbstractCommandHandler<C, E, S> handler) {
    Option<Object> error = handler.getValidationError(lastSequenceNr());
    if (error.isDefined()) {
        log.debug("  invalid: {}", error.get());
        sender().tell(error.get(), self());
    } else if (handler.isAlreadyApplied()) {
        log.debug("  was already applied.");
        sender().tell(handler.getIdempotentReply(lastSequenceNr()), self());
    } else {
        Seq<E> events = handler.getEventsToEmit();
        log.debug("  emitting {}", events);
        if (events.isEmpty()) {
            sender().tell(handler.getReply(events, lastSequenceNr()), self());
        } else {
            if (lastSequenceNr() == 0) {
                validateFirstEvent(events.head());
            }
            AtomicInteger need = new AtomicInteger(events.size());
            persistAllEvents(events, evt -> {
                if (need.decrementAndGet() == 0) {
                    sender().tell(handler.getReply(events, lastSequenceNr()), self());
                }
            });
        }
    }
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:30,代码来源:AbstractStatefulPersistentActor.java

示例13: getDataCenterNames

import io.vavr.collection.Seq; //导入依赖的package包/类
@Override
public Seq<String> getDataCenterNames(TestEvent e) {
    if (e.getMsg().startsWith("dc:")) {
        return Vector.of(e.getMsg().substring(3));
    } else {
        return Vector.empty();
    }
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:9,代码来源:TestEventClassifier.java

示例14: store

import io.vavr.collection.Seq; //导入依赖的package包/类
/**
 * Stores the given buffered events into S3, under a key that includes the tag and the offset of the first event.
 * @param tag Persistence tag that the events were for
 */
public CompletionStage<Done> store(String tag, Seq<EventEnvelope> events) {
    String key = tag + SEPARATOR + FMT.format(Instant.ofEpochMilli(UUIDs.unixTimestamp(TimeBasedUUID.class.cast(events.get(0).offset()).value())));
    return Source.from(events)
          .map(e -> {
              ByteStringBuilder b = new ByteStringBuilder();
              serializer.toProtobuf(e).writeDelimitedTo(b.asOutputStream());
              return b.result();
          })
          .runWith(upload(key), materializer)
          .thenApply(result -> {
              log.info("Uploaded to {} with etag {}", result.key(), result.etag());
              return Done.getInstance();
          });
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:19,代码来源:S3.java

示例15: ObjectWriteProtocol

import io.vavr.collection.Seq; //导入依赖的package包/类
ObjectWriteProtocol(
    Seq<WriteProtocol<JSONEvent, ?>> protocols,
    List<Function1<T, ?>> getters,
    Seq<WriteProtocol<JSONEvent, ConstantProtocol.Present>> conditions
) {
    this.protocols = protocols;
    this.getters = getters;
    this.conditions = conditions;
    if (protocols.size() != getters.size()) {
        throw new IllegalArgumentException("protocols must match getters");
    }
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:13,代码来源:ObjectWriteProtocol.java


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