net.digitalid.utility.property.map.WritableVolatileMapPropertySubclass Maven / Gradle / Ivy
The newest version!
package net.digitalid.utility.property.map;
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.map.FreezableMap;
import net.digitalid.utility.collections.map.ReadOnlyMap;
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.122+0200")
class WritableVolatileMapPropertySubclass, FREEZABLE_MAP extends FreezableMap> extends WritableVolatileMapProperty {
/* -------------------------------------------------- Value Validator -------------------------------------------------- */
private final Predicate super VALUE> valueValidator;
@Override
public Predicate super VALUE> getValueValidator() {
Predicate super VALUE> result = this.valueValidator;
return result;
}
/* -------------------------------------------------- Key Validator -------------------------------------------------- */
private final Predicate super KEY> keyValidator;
@Override
public Predicate super KEY> getKeyValidator() {
Predicate super KEY> result = this.keyValidator;
return result;
}
/* -------------------------------------------------- Map -------------------------------------------------- */
private final FREEZABLE_MAP map;
@Override
protected FREEZABLE_MAP getMap() {
FREEZABLE_MAP result = this.map;
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 -------------------------------------------------- */
WritableVolatileMapPropertySubclass(Predicate super VALUE> valueValidator, Predicate super KEY> keyValidator, FREEZABLE_MAP map) throws RuntimeException {
super();
this.valueValidator = valueValidator;
this.keyValidator = keyValidator;
this.map = map;
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 isValidKey(KEY key) {
boolean result = super.isValidKey(key);
return result;
}
@Override
protected void initialize() throws RuntimeException {
super.initialize();
}
@Override
public boolean register(VolatileMapObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.register(observer);
return result;
}
@Override
public boolean deregister(VolatileMapObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.deregister(observer);
return result;
}
@Override
public boolean isRegistered(VolatileMapObserver 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(VolatileMapObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.registerOnGuiThread(observer);
return result;
}
@Override
public boolean registerOnNewThread(VolatileMapObserver observer) {
Require.that(observer != null).orThrow("The observer may not be null.", observer);
boolean result = super.registerOnNewThread(observer);
return result;
}
@Override
protected void notifyObservers(KEY key, VALUE value, boolean added) throws RuntimeException, RuntimeException {
Require.that(key != null).orThrow("The key may not be null.", key);
Require.that(key == null || isValidKey(key)).orThrow("The key has to be null or valid but was $.", key);
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(key, value, added);
}
@Override
public READONLY_MAP get() {
READONLY_MAP 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 VALUE get(KEY key) {
Require.that(key != null).orThrow("The key may not be null.", key);
Require.that(key == null || isValidKey(key)).orThrow("The key has to be null or valid but was $.", key);
VALUE result = super.get(key);
Ensure.that(result == null || isValid(result)).orThrow("The result has to be null or valid but was $.", result);
return result;
}
@Override
public boolean add(KEY key, VALUE value) {
Require.that(key != null).orThrow("The key may not be null.", key);
Require.that(key == null || isValidKey(key)).orThrow("The key has to be null or valid but was $.", key);
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(key, value);
return result;
}
@Override
public VALUE remove(KEY key) {
Require.that(key != null).orThrow("The key may not be null.", key);
Require.that(key == null || isValidKey(key)).orThrow("The key has to be null or valid but was $.", key);
Require.that(!isLockHeldByCurrentThread()).orThrow("The method 'remove' may only be called by a thread that does not hold the lock.");
VALUE result = super.remove(key);
Ensure.that(result == null || isValid(result)).orThrow("The result has to be null or valid but was $.", result);
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 WritableVolatileMapProperty)) {
return false;
}
final @Nonnull WritableVolatileMapProperty that = (WritableVolatileMapProperty) object;
boolean result = true;
result = result && Objects.equals(this.getValueValidator(), that.getValueValidator());
result = result && Objects.equals(this.getKeyValidator(), that.getKeyValidator());
result = result && Objects.equals(this.getMap(), that.getMap());
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(getKeyValidator());
result = prime * result + Objects.hashCode(getMap());
return result;
}
@Pure
@Override
public String toString() {
return "WritableVolatileMapProperty(valueValidator: " + getValueValidator() + ", keyValidator: " + getKeyValidator() + ", map: " + getMap() + ")";
}
@Pure
@Override
public void validate() {
super.validate();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy