io.vavr.collection.IndexedSeq Java Examples

The following examples show how to use io.vavr.collection.IndexedSeq. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TableComponent.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
    DataFrame dataFrame = params.dataFrame;
    java.util.List<MarkupTableColumn> columnSpecs = dataFrame.getColumns().map(column -> {
                Integer widthRatio = Integer.valueOf(column.getMetaData().get(WIDTH_RATIO).getOrElse("0"));
                return new MarkupTableColumn(column.getId().getName())
                        .withWidthRatio(widthRatio)
                        .withHeaderColumn(Boolean.parseBoolean(column.getMetaData().get(HEADER_COLUMN).getOrElse("false")))
                        .withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^" + widthRatio + "a");
            }
    ).toJavaList();

    IndexedSeq<IndexedSeq<String>> columnValues = dataFrame.getColumns()
            .map(column -> ((StringColumn) column).getValues());

    java.util.List<java.util.List<String>> cells = Array.range(0, dataFrame.getRowCount())
            .map(rowNumber -> columnValues.map(values -> values.get(rowNumber)).toJavaList()).toJavaList();

    return markupDocBuilder.tableWithColumnSpecs(columnSpecs, cells);
}
 
Example #2
Source File: ReadmeTest.java    From paleo with Apache License 2.0 5 votes vote down vote up
@Test
public void demo() {

    final String EXAMPLE =
            "Name\tColor\tServing Size (g)\n" +
                    "String\tCategory\tDouble\n" +
                    "Banana\tYellow\t118\n" +
                    "Blueberry\tBlue\t148\n" +
                    "Lemon\tYellow\t83\n" +
                    "Apple\tGreen\t182";


    DataFrame dataFrame = Parser.tsv(new StringReader(EXAMPLE));

    // Lookup typed identifiers by column index
    final StringColumnId NAME = dataFrame.getColumnId(0, ColumnType.STRING);
    final CategoryColumnId COLOR = dataFrame.getColumnId(1, ColumnType.CATEGORY);
    final DoubleColumnId SERVING_SIZE = dataFrame.getColumnId(2, ColumnType.DOUBLE);

    // Use identifier to access columns & values
    StringColumn nameColumn = dataFrame.getColumn(NAME);
    IndexedSeq<String> nameValues = nameColumn.getValues();

    // ... or access individual values via row index / column id
    String yellow = dataFrame.getValueAt(2, COLOR);

}
 
Example #3
Source File: Schema.java    From paleo with Apache License 2.0 4 votes vote down vote up
public IndexedSeq<Field> getFields() {
    return fields;
}
 
Example #4
Source File: AbstractColumn.java    From paleo with Apache License 2.0 4 votes vote down vote up
protected AbstractColumn(I id, IndexedSeq<V> values, Map<String, String> metaData) {
    this.id = id;
    this.values = values;
    this.metaData = metaData;
}
 
Example #5
Source File: AbstractColumn.java    From paleo with Apache License 2.0 4 votes vote down vote up
public final IndexedSeq<V> getValues() {
    return values;
}
 
Example #6
Source File: IndexedSeqTest.java    From vavr-jackson with Apache License 2.0 4 votes vote down vote up
@Override
protected TypeReference<IndexedSeq<Option<String>>> typeReferenceWithOption() {
    return new TypeReference<IndexedSeq<Option<String>>>() {};
}