com.github.alexmojaki.caseclasses.CollectionBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of case-classes Show documentation
Show all versions of case-classes Show documentation
A framework to refactor computing a result from an aggregate object.
The newest version!
package com.github.alexmojaki.caseclasses;
import java.util.Collection;
class CollectionBuilder extends AbstractResultBuilder {
private Collection collection;
private Class type;
@SuppressWarnings("unchecked")
static , E> void addValues(CaseClass obj, T collection, Class type) {
CollectionBuilder builder = new CollectionBuilder();
builder.collection = collection;
builder.type = type;
obj.buildResult(builder);
}
static void addValues(CaseClass obj, T collection) {
addValues(obj, collection, Object.class);
}
@Override
public void simpleAdd(String name, Object value) {
collection.add(type.cast(value));
}
}