
eu.mihosoft.vmf.vmftext.grammar.impl.ReadOnlyUnparserModelImpl Maven / Gradle / Ivy
package eu.mihosoft.vmf.vmftext.grammar.impl;
// vmf imports
//import eu.mihosoft.vmf.runtime.core.*;
//import eu.mihosoft.vmf.runtime.core.internal.*;
import eu.mihosoft.vcollections.*;
import eu.mihosoft.vmf.vmftext.grammar.*;
import java.beans.PropertyChangeListener;
// property types imports
import eu.mihosoft.vcollections.*;
// interface
/**
* An read-only representation of the model object {@code eu.mihosoft.vmf.vmftext.grammar.UnparserModel}.
*/
@SuppressWarnings("deprecation")
class ReadOnlyUnparserModelImpl implements ReadOnlyUnparserModel, eu.mihosoft.vmf.runtime.core.internal.VObjectInternal, VCloneableInternal {
private final UnparserModel mutableObject;
// Read-only view for collection properties
// - properties with collection type (model & non-model collections)
// - we don't allow/provide setters for collection properties
private VList lexerRules;
private VList rules;
public ReadOnlyUnparserModelImpl(UnparserModel mutableObject) {
this.mutableObject = mutableObject;
}
@Override
// generic type is a model-type
public VList getLexerRules() {
// we return an unmodifiable mapped list that contains read-only versions of the list elements
// since read-only types and normal types are incompatible by design, we specify the lambda
// operation that converts an element into a read-only version of that element
if(this.lexerRules == null) {
this.lexerRules = VMappedList.newUnmodifiableInstance(mutableObject.getLexerRules(), (e)->e.asReadOnly());
}
return this.lexerRules;
}
@Override
// generic type is a model-type
public VList getRules() {
// we return an unmodifiable mapped list that contains read-only versions of the list elements
// since read-only types and normal types are incompatible by design, we specify the lambda
// operation that converts an element into a read-only version of that element
if(this.rules == null) {
this.rules = VMappedList.newUnmodifiableInstance(mutableObject.getRules(), (e)->e.asReadOnly());
}
return this.rules;
}
// end for each property
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {
((eu.mihosoft.vmf.runtime.core.internal.VObjectInternal)this.mutableObject).addPropertyChangeListener(l);
}
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
((eu.mihosoft.vmf.runtime.core.internal.VObjectInternal)this.mutableObject).removePropertyChangeListener(l);
}
@Override
public String toString() {
return this.mutableObject.toString();
}
@Override
public boolean equals(Object o) {
return this.mutableObject.equals(o);
}
@Override
public int hashCode() {
return this.mutableObject.hashCode();
}
@Override
public UnparserModel _vmf_getMutableObject() {
return this.mutableObject;
}
@Override
public ReadOnlyUnparserModelImpl asReadOnly() {
return this;
}
// --------------------------------------------------------------------
// --- Cloning
// --------------------------------------------------------------------
@Override
public ReadOnlyUnparserModel clone() {
return this.mutableObject.clone().asReadOnly();
}
@Override
public UnparserModel asModifiable() {
return this.mutableObject.clone();
}
@Override
public UnparserModel _vmf_deepCopy(
java.util.IdentityHashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy