org.bklab.crud.grid.FluentColumnRender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-vaadin-flow Show documentation
Show all versions of fluent-vaadin-flow Show documentation
Broderick Labs for fluent vaadin flow. Inherits common Vaadin components.
package org.bklab.crud.grid;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.function.ValueProvider;
import java.util.function.BiConsumer;
public class FluentColumnRender {
private final String id;
private final String name;
private final ValueProvider componentProvider;
private BiConsumer writeComponentConsumer;
private BiConsumer writeEntityConsumer;
private BiConsumer, C> binderConsumer;
public FluentColumnRender(String id, String name, ValueProvider supplier) {
this.id = id;
this.name = name;
this.componentProvider = supplier;
}
public FluentColumnRender binderConsumer(BiConsumer, C> binderConsumer) {
this.binderConsumer = binderConsumer;
return this;
}
public C createComponent(T entity) {
return componentProvider.apply(entity);
}
public void writeEntity(T entity, Component c) {
if (writeEntityConsumer != null)
//noinspection unchecked
writeEntityConsumer.accept(entity, (C) c);
}
public void writeComponent(T entity, Component c) {
if (writeComponentConsumer != null)
//noinspection unchecked
writeComponentConsumer.accept(entity, (C) c);
}
public BiConsumer, C> getBinderConsumer() {
return binderConsumer;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public ValueProvider getComponentProvider() {
return componentProvider;
}
public BiConsumer getWriteComponentConsumer() {
return writeComponentConsumer;
}
public FluentColumnRender setWriteComponentConsumer(BiConsumer writeComponentConsumer) {
this.writeComponentConsumer = writeComponentConsumer;
return this;
}
public BiConsumer getWriteEntityConsumer() {
return writeEntityConsumer;
}
public FluentColumnRender setWriteEntityConsumer(BiConsumer writeEntityConsumer) {
this.writeEntityConsumer = writeEntityConsumer;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy