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

de.tsl2.nano.h5.collector.Increaser Maven / Gradle / Ivy

Go to download

TSL2 Framework Html5 Extensions (WebServer, Html5Presentation, RuleCover, BeanConfigurator, LogicTable-Sheet, Expression-Descriptors for Actions, Rules, URLs, Queries)

There is a newer version: 2.5.2
Show newest version
/*
 * File: $HeadURL$
 * Id  : $Id$
 * 
 * created by: Tom, Thomas Schneider
 * created on: 24.07.2017
 * 
 * Copyright: (c) Thomas Schneider 2017, all rights reserved
 */
package de.tsl2.nano.h5.collector;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

import de.tsl2.nano.bean.BeanUtil;
import de.tsl2.nano.bean.def.BeanCollector;
import de.tsl2.nano.bean.def.IAttributeDefinition;

/**
 * holds properties to create new instances with an increasing attribute
 * 
 * @author Tom, Thomas Schneider
 * @version $Revision$
 */
public class Increaser implements IItemProvider, Serializable {

    private static final long serialVersionUID = 4984470230289140956L;

    
    private int count;
    private int step;
    private String name;

    protected Increaser() {
    }

    /**
     * constructor
     */
    public Increaser(String name, int count, int step) {
        this.name = name;
        this.count = count;
        this.step = step;
    }

    @Override
    public T createItem(T srcInstance, Map context) {
        throw new UnsupportedOperationException();
    }

    @Override
    public Collection createItems(T srcInstance, Map context) {
        return BeanUtil.create(srcInstance, name, null, count, step);
    }

    public String getName() {
        return name;
    }

    public void check(BeanCollector, T> caller) {
        IAttributeDefinition attribute = caller.getAttribute(getName());
        createItems(caller.createItem(null), null);
    }

    public int getCount() {
        return count;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy