package org.cyclops.integrateddynamics.core.part.aspect.property;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import lombok.Data;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectPropertyTypeInstance;

/**
 * An instance of a property type with a onLabelPacket.
 * @author rubensworks
 */
@Data
public class AspectPropertyTypeInstance<T extends IValueType<V>, V extends IValue> implements IAspectPropertyTypeInstance<T, V> {

    private final T type;
    private final String unlocalizedName;
    private final Predicate<V> validator;

    public AspectPropertyTypeInstance(T type, String unlocalizedName) {
        this(type, unlocalizedName, Predicates.<V>alwaysTrue());
    }

    public AspectPropertyTypeInstance(T type, String unlocalizedName, Predicate<V> validator) {
        this.type = type;
        this.unlocalizedName = unlocalizedName;
        this.validator = validator;
    }
}

@@ -1086,11 +1086,418 @@
 r;%0A    %7D
+%0A%0A    @Override%0A    public boolean equals(Object o) %7B%0A        return o instanceof AspectPropertyTypeInstance%0A                && ((AspectPropertyTypeInstance) o).type.equals(this.type)%0A                && ((AspectPropertyTypeInstance) o).unlocalizedName.equals(this.unlocalizedName);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return unlocalizedName.hashCode() + type.hashCode() %3C%3C 2 + 11;%0A    %7D
 %0A%7D%0A

Fix part aspect settings not being restored on world load, Closes CyclopsMC/IntegratedTunnels#30 This was caused by aspect property instances including the new validator predicates in their equals implementation, which always resulted in a failure.