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

org.openfact.component.PrioritizedComponentModel Maven / Gradle / Ivy

There is a newer version: 1.1.3.Final
Show newest version
package org.openfact.component;

import java.util.Comparator;

public class PrioritizedComponentModel extends ComponentModel {

    public static final String PRIORITY = "priority";

    public static Comparator comparator = new Comparator() {
        @Override
        public int compare(ComponentModel o1, ComponentModel o2) {
            return parsePriority(o1) - parsePriority(o2);
        }
    };

    public PrioritizedComponentModel(ComponentModel copy) {
        super(copy);
    }

    public PrioritizedComponentModel() {
    }

    public static int parsePriority(ComponentModel component) {
        String priority = component.getConfig().getFirst(PRIORITY);
        if (priority == null) return 0;
        return Integer.valueOf(priority);
    }

    public int getPriority() {
        return parsePriority(this);
    }

    public void setPriority(int priority) {
        getConfig().putSingle("priority", Integer.toString(priority));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy