com.artemis.ConfigurationElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artemis-odb Show documentation
Show all versions of artemis-odb Show documentation
Fork of Artemis Entity System Framework.
package com.artemis;
import java.lang.Class;import java.lang.Comparable;import java.lang.Object;import java.lang.Override;
/**
* Artemis pieces with priority pending registration.
*
* @author Daan van Yperen
* @see WorldConfigurationBuilder
*/
class ConfigurationElement implements Comparable> {
public final int priority;
public final Class> itemType;
public T item;
public ConfigurationElement(T item, int priority) {
this.item = item;
itemType = item.getClass();
this.priority = priority;
}
@Override
public int compareTo(ConfigurationElement o) {
// Sort by priority descending.
return Integer.compare(o.priority, priority);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return item.equals(((ConfigurationElement>) o).item);
}
@Override
public int hashCode() {
return item.hashCode();
}
/** create instance of Registerable. */
public static ConfigurationElement of(T item) {
return of(item, WorldConfigurationBuilder.Priority.NORMAL);
}
/** create instance of Registerable. */
public static ConfigurationElement of(T item, int priority) {
return new ConfigurationElement(item, priority);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy