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

net.digitalid.utility.property.set.WritableVolatileSetPropertySubclass Maven / Gradle / Ivy

The newest version!
package net.digitalid.utility.property.set;

import java.util.Objects;

import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.digitalid.utility.annotations.method.Pure;
import net.digitalid.utility.collections.set.FreezableSet;
import net.digitalid.utility.collections.set.ReadOnlySet;
import net.digitalid.utility.contracts.Ensure;
import net.digitalid.utility.contracts.Require;
import net.digitalid.utility.functional.interfaces.Predicate;

@SuppressWarnings("null")
@Generated(value = "net.digitalid.utility.processor.generator.JavaFileGenerator", date = "2017-03-26T11:54:50.025+0200")
class WritableVolatileSetPropertySubclass, FREEZABLE_SET extends FreezableSet> extends WritableVolatileSetProperty {
    
    /* -------------------------------------------------- Value Validator -------------------------------------------------- */
    
    private final Predicate valueValidator;
    
    @Override
    public Predicate getValueValidator() {
        Predicate result = this.valueValidator;
        return result;
    }
    
    /* -------------------------------------------------- Set -------------------------------------------------- */
    
    private final FREEZABLE_SET set;
    
    @Override
    protected FREEZABLE_SET getSet() {
        FREEZABLE_SET result = this.set;
        Ensure.that(result != null).orThrow("The result may not be null.", result);
        Ensure.that(result == null || !result.isFrozen()).orThrow("The result has to be null or may not be frozen.", result);
        return result;
    }
    
    /* -------------------------------------------------- Constructors -------------------------------------------------- */
    
    WritableVolatileSetPropertySubclass(Predicate valueValidator, FREEZABLE_SET set) throws RuntimeException {
        super();
        
        this.valueValidator = valueValidator;
        this.set = set;
        initialize();
        validate();
    }
    
    /* -------------------------------------------------- Overridden Methods -------------------------------------------------- */
    
    @Override
    public  T castTo(Class targetClass) {
        T result = super.castTo(targetClass);
        Ensure.that(result == this).orThrow("The result has to be  but was $.", result);
        return result;
    }
    
    @Override
    public boolean isValid(VALUE value) {
        boolean result = super.isValid(value);
        return result;
    }
    
    @Override
    protected void initialize() throws RuntimeException {
        super.initialize();
    }
    
    @Override
    public boolean register(VolatileSetObserver observer) {
        Require.that(observer != null).orThrow("The observer may not be null.", observer);
        boolean result = super.register(observer);
        return result;
    }
    
    @Override
    public boolean deregister(VolatileSetObserver observer) {
        Require.that(observer != null).orThrow("The observer may not be null.", observer);
        boolean result = super.deregister(observer);
        return result;
    }
    
    @Override
    public boolean isRegistered(VolatileSetObserver observer) {
        Require.that(observer != null).orThrow("The observer may not be null.", observer);
        boolean result = super.isRegistered(observer);
        return result;
    }
    
    @Override
    public boolean isLockHeldByCurrentThread() {
        boolean result = super.isLockHeldByCurrentThread();
        return result;
    }
    
    @Override
    public boolean registerOnGuiThread(VolatileSetObserver observer) {
        Require.that(observer != null).orThrow("The observer may not be null.", observer);
        boolean result = super.registerOnGuiThread(observer);
        return result;
    }
    
    @Override
    public boolean registerOnNewThread(VolatileSetObserver observer) {
        Require.that(observer != null).orThrow("The observer may not be null.", observer);
        boolean result = super.registerOnNewThread(observer);
        return result;
    }
    
    @Override
    protected void notifyObservers(VALUE value, boolean added) throws RuntimeException, RuntimeException {
        Require.that(value != null).orThrow("The value may not be null.", value);
        Require.that(value == null || isValid(value)).orThrow("The value has to be null or valid but was $.", value);
        super.notifyObservers(value, added);
    }
    
    @Override
    public READONLY_SET get() {
        READONLY_SET result = super.get();
        Ensure.that(result != null).orThrow("The result may not be null.", result);
        Ensure.that(result == null || !result.isFrozen()).orThrow("The result has to be null or may not be frozen.", result);
        return result;
    }
    
    @Override
    public boolean add(VALUE value) {
        Require.that(value != null).orThrow("The value may not be null.", value);
        Require.that(value == null || isValid(value)).orThrow("The value has to be null or valid but was $.", value);
        Require.that(!isLockHeldByCurrentThread()).orThrow("The method 'add' may only be called by a thread that does not hold the lock.");
        boolean result = super.add(value);
        return result;
    }
    
    @Override
    public boolean remove(VALUE value) {
        Require.that(value != null).orThrow("The value may not be null.", value);
        Require.that(value == null || isValid(value)).orThrow("The value has to be null or valid but was $.", value);
        Require.that(!isLockHeldByCurrentThread()).orThrow("The method 'remove' may only be called by a thread that does not hold the lock.");
        boolean result = super.remove(value);
        return result;
    }
    
    /* -------------------------------------------------- Implement Methods -------------------------------------------------- */
    
    /* -------------------------------------------------- Generated Methods -------------------------------------------------- */
    
    /**
     * Returns false if the given object is not equal to the current object, using the heuristics that fields of a class, which are handed to the class via the recovery method or the constructor, must be equal to each other, so that the objects are considered equal.
     */
    @Pure
    @Override
    public boolean equals(@Nullable Object object) {
        if (object == this) {
            return true;
        }
        if (object == null || !(object instanceof WritableVolatileSetProperty)) {
            return false;
        }
        final @Nonnull WritableVolatileSetProperty that = (WritableVolatileSetProperty) object;
        boolean result = true;
        result = result && Objects.equals(this.getValueValidator(), that.getValueValidator());
        result = result && Objects.equals(this.getSet(), that.getSet());
        return result;
    }
    
    /**
     * Computes and returns the hash code of this object, using the fields of the class which are handed to the class via the recovery method or the constructor.
     */
    @Pure
    @Override
    public int hashCode() {
        int prime = 92_821;
        int result = 46_411;
        result = prime * result + Objects.hashCode(getValueValidator());
        result = prime * result + Objects.hashCode(getSet());
        return result;
    }
    
    @Pure
    @Override
    public String toString() {
        return "WritableVolatileSetProperty(valueValidator: " + getValueValidator() + ", set: " + getSet() + ")";
    }
    
    @Pure
    @Override
    public void validate() {
        super.validate();
    }
    
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy