package de.frajul.particlelab.entities.particles.attributes;

import java.util.ArrayList;
import java.util.List;

import de.frajul.particlelab.entities.particles.attributes.attributeValues.ParticleAttributeValue;
import de.frajul.particlelab.entities.particles.attributes.attributeValues.ParticleAttributeValueType;

/**
 * Created by Julian on 02.08.2016.
 */
public class Attribute {

    private ParticleAttributeType type;
    private List<ParticleAttributeValue> values = new ArrayList<>();

    public Attribute(ParticleAttributeType type, ParticleAttributeValueType... valueTypes) {
        this.type = type;
        for (ParticleAttributeValueType valueType : valueTypes)
            values.add(valueType.createInstance());
    }

    public ParticleAttributeValue get(ParticleAttributeValueType valueType) throws Exception {
        for (ParticleAttributeValue v : values)
            if (v.getType() == valueType)
                return v;
        throw new Exception("ParticleAttributeValue with type: " + valueType + " does not exist in Attribute "+type);
    }

    public ParticleAttributeType getType() {
        return type;
    }
}
