
com.inamik.text.tables.cell.BottomTruncate Maven / Gradle / Ivy
The newest version!
/*
* iNamik Text Tables for Java
*
* Copyright (C) 2016 David Farrell ([email protected])
*
* Licensed under The MIT License (MIT), see LICENSE.txt
*/
package com.inamik.text.tables.cell;
import com.inamik.text.tables.cell.base.FunctionWithHeight;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public final class BottomTruncate extends FunctionWithHeight
{
public static final BottomTruncate INSTANCE = new BottomTruncate();
@Override
public Collection apply(Integer height, Collection cell) {
// Any truncating needed?
//
if (cell.size() <= height) {
return cell;
}
List newCell = new ArrayList(height);
for (String line: cell) {
// Skip last n lines
//
if (newCell.size() >= height) { break; }
newCell.add(line);
}
return newCell;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy