All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.leeonky.jfactory.CollectionInstance Maven / Gradle / Ivy

There is a newer version: 0.7.2
Show newest version
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