
com.inamik.text.tables.cell.base.FunctionWithCharAndWidthAndHeight 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.base;
import java.util.Collection;
public abstract class FunctionWithCharAndWidthAndHeight
{
public abstract Collection apply(Character character, Integer width, Integer height, Collection cell);
public static final FunctionWithCharAndWidthAndHeight IDENTITY = new FunctionWithCharAndWidthAndHeight() {
@Override
public FunctionWithWidthAndHeight withChar(char _1) { return FunctionWithWidthAndHeight.IDENTITY; }
@Override
public FunctionWithCharAndHeight withWidth(int _1) {
return FunctionWithCharAndHeight.IDENTITY;
}
@Override
public FunctionWithCharAndWidth withHeight(int _1) {
return FunctionWithCharAndWidth.IDENTITY;
}
@Override
public Collection apply(Character _1, Integer _2, Integer _3, Collection cell) { return cell; }
};
public FunctionWithWidthAndHeight withChar(final char character) {
// curry(this, character)
//
final FunctionWithCharAndWidthAndHeight f = this;
return new FunctionWithWidthAndHeight() {
@Override
public Collection apply(Integer width, Integer height, Collection cell) {
return f.apply(character, width, height, cell);
}
};
}
public FunctionWithCharAndHeight withWidth (final int width) {
// curry_2(this, width)
//
final FunctionWithCharAndWidthAndHeight f = this;
return new FunctionWithCharAndHeight() {
@Override
public Collection apply(Character character, Integer height, Collection cell) {
return f.apply(character, width, height, cell);
}
};
}
public FunctionWithCharAndWidth withHeight(final int height) {
// curry_3(this, height)
//
final FunctionWithCharAndWidthAndHeight f = this;
return new FunctionWithCharAndWidth() {
@Override
public Collection apply(Character character, Integer width, Collection cell) {
return f.apply(character, width, height, cell);
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy