com.github.leeonky.jfactory.CollectionInstance Maven / Gradle / Ivy
package com.github.leeonky.jfactory;
import com.github.leeonky.util.PropertyWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
class CollectionInstance extends SubInstance {
private final List indexes;
public CollectionInstance(List indexes, PropertyWriter> property, int sequence, Spec spec,
DefaultArguments argument) {
super(property, sequence, spec, argument);
this.indexes = new ArrayList<>(indexes);
}
@Override
public String propertyInfo() {
return String.format("%s%s", super.propertyInfo(),
indexes.stream().map(i -> String.format("[%d]", i)).collect(Collectors.joining()));
}
public CollectionInstance element(int index) {
CollectionInstance collection = new CollectionInstance<>(indexes, getProperty(), getSequence(), spec, arguments);
collection.indexes.add(index);
return collection;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy