net.digitalid.utility.property.value.WritableVolatileValuePropertySubclass Maven / Gradle / Ivy
The newest version!
package net.digitalid.utility.property.value;
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.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.060+0200")
class WritableVolatileValuePropertySubclass extends WritableVolatileValueProperty {
/* -------------------------------------------------- Value Validator -------------------------------------------------- */
private final Predicate super VALUE> valueValidator;
@Override
public Predicate super VALUE> getValueValidator() {
Predicate super VALUE> result = this.valueValidator;
return result;
}
/* -------------------------------------------------- Constructors -------------------------------------------------- */
WritableVolatileValuePropertySubclass(VALUE value, Predicate super VALUE> valueValidator) {
super(value);
this.valueValidator = valueValidator;
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
public boolean register(VolatileValueObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.register(observer);
return result;
}
@Override
public boolean deregister(VolatileValueObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.deregister(observer);
return result;
}
@Override
public boolean isRegistered(VolatileValueObserver 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(VolatileValueObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.registerOnGuiThread(observer);
return result;
}
@Override
public boolean registerOnNewThread(VolatileValueObserver 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 oldValue, VALUE newValue) throws RuntimeException, RuntimeException {
Require.that(isValid(oldValue)).orThrow("The old value has to be valid but was $.", oldValue);
Require.that(isValid(newValue)).orThrow("The new value has to be valid but was $.", newValue);
super.notifyObservers(oldValue, newValue);
}
@Override
public VALUE get() {
VALUE result = super.get();
Ensure.that(isValid(result)).orThrow("The result has to be valid but was $.", result);
return result;
}
@Override
public VALUE set(VALUE newValue) {
Require.that(isValid(newValue)).orThrow("The new value has to be valid but was $.", newValue);
Require.that(!isLockHeldByCurrentThread()).orThrow("The method 'set' may only be called by a thread that does not hold the lock.");
VALUE result = super.set(newValue);
Ensure.that(isValid(result)).orThrow("The result has to be valid but was $.", result);
return result;
}
@Override
protected void initialize() {
super.initialize();
}
/* -------------------------------------------------- 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 WritableVolatileValueProperty)) {
return false;
}
final @Nonnull WritableVolatileValueProperty that = (WritableVolatileValueProperty) object;
boolean result = true;
result = result && Objects.equals(this.getValueValidator(), that.getValueValidator());
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());
return result;
}
@Pure
@Override
public String toString() {
return "WritableVolatileValueProperty(valueValidator: " + getValueValidator() + ")";
}
@Pure
@Override
public void validate() {
super.validate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy