package fr.cenra.rhomeo.protocol.p06;

import fr.cenra.rhomeo.api.process.Indicator;
import fr.cenra.rhomeo.api.result.DefaultIndex;
import fr.cenra.rhomeo.api.result.Index;
import fr.cenra.rhomeo.api.result.IndexSpi;
import java.util.Collection;
import java.util.Collections;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *
 * @author Alexis Manin (Geomatys)
 */
@Component
public class BehaviorSpi implements IndexSpi<Float, Integer> {

    @Autowired
    I10 indic;

    @Override
    public Unit<?> getUnit() {
        return NonSI.PERCENT;
    }

    @Override
    public Indicator getIndicator() {
        return indic;
    }

    @Override
    public Index<Float> createIndex(Float value, Integer entity) {
        return new DefaultIndex<>(value, this, entity);
    }

    @Override
    public String getName() {
        return "behaviorIndex";
    }

    @Override
    public Collection<String> getAlias() {
        return Collections.singleton("Niveau d'autochtonie (%)");
    }

    @Override
    public String getRemarks() {
        return "Pourcentage de comportements immature, de ponte ou d'exuvie observé";
    }

    @Override
    public int compareTo(IndexSpi o) {
        final int comparison = IndexSpi.super.compareTo(o);
        if (comparison == 0)
            return 1;
        return comparison;
    }


}
