Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
eu.mihosoft.vmf.vmftext.grammar.impl.ReadOnlyUPNamedSubRuleElementImpl 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.UPNamedSubRuleElement}.
*/
@SuppressWarnings("deprecation")
class ReadOnlyUPNamedSubRuleElementImpl implements ReadOnlyUPNamedSubRuleElement, eu.mihosoft.vmf.runtime.core.internal.VObjectInternal, VCloneableInternal {
private final UPNamedSubRuleElement 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 alternatives;
public ReadOnlyUPNamedSubRuleElementImpl(UPNamedSubRuleElement mutableObject) {
this.mutableObject = mutableObject;
}
@Override
// generic type is a model-type
public VList getAlternatives() {
// 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.alternatives == null) {
this.alternatives = VMappedList.newUnmodifiableInstance(mutableObject.getAlternatives(), (e)->e.asReadOnly());
}
return this.alternatives;
}
@Override
public int getId() {
return this.mutableObject.getId();
}
@Override
public boolean isLexerRule() {
return this.mutableObject.isLexerRule();
}
@Override
public boolean isListType() {
return this.mutableObject.isListType();
}
@Override
public java.lang.String getName() {
return this.mutableObject.getName();
}
@Override
public boolean isNegated() {
return this.mutableObject.isNegated();
}
@Override
// property type is a model-type
public ReadOnlyAlternativeBase getParentAlt() {
if(this.mutableObject.getParentAlt()!=null) {
return this.mutableObject.getParentAlt().asReadOnly();
} else {
return null;
}
}
@Override
public boolean isParserRule() {
return this.mutableObject.isParserRule();
}
@Override
public java.lang.String getRuleName() {
return this.mutableObject.getRuleName();
}
@Override
public boolean isTerminal() {
return this.mutableObject.isTerminal();
}
@Override
public java.lang.String getText() {
return this.mutableObject.getText();
}
// 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 UPNamedSubRuleElement _vmf_getMutableObject() {
return this.mutableObject;
}
@Override
public ReadOnlyUPNamedSubRuleElementImpl asReadOnly() {
return this;
}
// --------------------------------------------------------------------
// --- Cloning
// --------------------------------------------------------------------
@Override
public ReadOnlyUPNamedSubRuleElement clone() {
return this.mutableObject.clone().asReadOnly();
}
@Override
public UPNamedSubRuleElement asModifiable() {
return this.mutableObject.clone();
}
@Override
public UPNamedSubRuleElement _vmf_deepCopy(
java.util.IdentityHashMap identityMap) {
return (UPNamedSubRuleElement)
((VCloneableInternal)this.mutableObject)._vmf_deepCopy(
new java.util.IdentityHashMap<>());
}
@Override
public ReadOnlyUPNamedSubRuleElement _vmf_shallowCopy(
java.util.IdentityHashMap identityMap) {
return (ReadOnlyUPNamedSubRuleElement)
((VCloneableInternal)this.mutableObject)._vmf_shallowCopy(
new java.util.IdentityHashMap<>()).asReadOnly();
}
// --------------------------------------------------------------------
// --- Public VMF API
// --------------------------------------------------------------------
@Override
public eu.mihosoft.vmf.runtime.core.VMF vmf() {
return new eu.mihosoft.vmf.runtime.core.VMF() {
public eu.mihosoft.vmf.runtime.core.Content content() {
return new eu.mihosoft.vmf.runtime.core.Content() {
public eu.mihosoft.vmf.runtime.core.VIterator iterator() {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyUPNamedSubRuleElementImpl.this);
}
public java.util.stream.Stream stream() {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyUPNamedSubRuleElementImpl.this).asStream();
}
public eu.mihosoft.vmf.runtime.core.VIterator iterator(eu.mihosoft.vmf.runtime.core.VIterator.IterationStrategy strategy) {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyUPNamedSubRuleElementImpl.this, strategy);
}
public java.util.stream.Stream stream(eu.mihosoft.vmf.runtime.core.VIterator.IterationStrategy strategy) {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyUPNamedSubRuleElementImpl.this, strategy).asStream();
}
public java.util.stream.Stream stream(Class type) {
return stream().filter(e->type.isAssignableFrom(e.getClass())).map(e->(T)e);
}
public java.util.stream.Stream stream(Class type, eu.mihosoft.vmf.runtime.core.VIterator.IterationStrategy strategy) {
return stream(strategy).filter(e->type.isAssignableFrom(e.getClass())).map(e->(T)e);
}
public VList referencedBy() {
return _vmf_referencedBy().asUnmodifiable();
}
public VList references() {
return _vmf_references().asUnmodifiable();
}
@Override
public ReadOnlyUPNamedSubRuleElement deepCopy() {
return (ReadOnlyUPNamedSubRuleElementImpl)
((VCloneableInternal)ReadOnlyUPNamedSubRuleElementImpl.this.mutableObject)._vmf_deepCopy(
new java.util.IdentityHashMap<>()).asReadOnly();
}
@Override
public ReadOnlyUPNamedSubRuleElement shallowCopy() {
return ReadOnlyUPNamedSubRuleElementImpl.
this._vmf_shallowCopy(new java.util.IdentityHashMap<>());
}
};
}
private eu.mihosoft.vmf.runtime.core.internal.ReflectImpl reflect;
public eu.mihosoft.vmf.runtime.core.Reflect reflect() {
if (reflect==null) {
reflect = new eu.mihosoft.vmf.runtime.core.internal.ReflectImpl();
reflect.setModel(ReadOnlyUPNamedSubRuleElementImpl.this);
}
return reflect;
}
}; // end vmf
}
// --------------------------------------------------------------------
// --- Reflection methods
// --------------------------------------------------------------------
// type id for improved reflection performance
public static final int _VMF_TYPE_ID = 45;
@Override
public int _vmf_getTypeId() {
return _VMF_TYPE_ID;
}
static final String[] _VMF_PROPERTY_NAMES = {
"alternatives",
"id",
"lexerRule",
"listType",
"name",
"negated",
"parentAlt",
"parserRule",
"ruleName",
"terminal",
"text"
};
static final String[] _VMF_PROPERTY_TYPE_NAMES = {
"eu.mihosoft.vcollections.VList", // type id -2
"int", // type id -1
"boolean", // type id -1
"boolean", // type id -1
"java.lang.String", // type id -1
"boolean", // type id -1
"eu.mihosoft.vmf.vmftext.grammar.AlternativeBase", // type id 2
"boolean", // type id -1
"java.lang.String", // type id -1
"boolean", // type id -1
"java.lang.String" // type id -1
};
static final int[] _VMF_PROPERTY_TYPES = {
-2, // type eu.mihosoft.vcollections.VList
-1, // type int
-1, // type boolean
-1, // type boolean
-1, // type java.lang.String
-1, // type boolean
2, // type eu.mihosoft.vmf.vmftext.grammar.AlternativeBase
-1, // type boolean
-1, // type java.lang.String
-1, // type boolean
-1 // type java.lang.String
};
/**
* - indices of model objects as properties
* - parents, i.e., containers are skipped
* - only indices of reference properties and contained elements, i.e.,
* children are listed here
*/
static final int[] _VMF_PROPERTIES_WITH_MODEL_TYPES_INDICES = {
};
/**
* - indices of lists that contain model objects as elements
*/
static final int[] _VMF_PROPERTIES_WITH_MODEL_ELEMENT_TYPES_INDICES = {
0, // type eu.mihosoft.vcollections.VList
};
/**
* - indices of model objects as properties and model objects as
* elements of lists
* - parents, i.e., containers are skipped
* - only indices of reference properties and contained elements, i.e.,
* children are listed here
*/
static final int[] _VMF_PROPERTIES_WITH_MODEL_TYPE_OR_ELEMENT_TYPES_INDICES = {
0, // type eu.mihosoft.vcollections.VList
};
/**
* - indices of model children
* - parents, i.e., containers and pure references are skipped
* - only indices of contained elements, i.e.,
* children are listed here
*/
static final int[] _VMF_CHILDREN_INDICES = {
0, // type eu.mihosoft.vcollections.VList
};
@Override
public String[] _vmf_getPropertyNames() {
return _VMF_PROPERTY_NAMES;
}
@Override
public int[] _vmf_getPropertyTypes() {
return _VMF_PROPERTY_TYPES;
}
@Override
public String[] _vmf_getPropertyTypeNames() {
return _VMF_PROPERTY_TYPE_NAMES;
}
@Override
public int[] _vmf_getIndicesOfPropertiesWithModelTypes() {
return _VMF_PROPERTIES_WITH_MODEL_TYPES_INDICES;
}
@Override
public int[] _vmf_getIndicesOfPropertiesWithModelElementTypes() {
return _VMF_PROPERTIES_WITH_MODEL_ELEMENT_TYPES_INDICES;
}
@Override
public int[] _vmf_getIndicesOfPropertiesWithModelTypeOrElementTypes() {
return _VMF_PROPERTIES_WITH_MODEL_TYPE_OR_ELEMENT_TYPES_INDICES;
}
@Override
public int[] _vmf_getChildrenIndices() {
return _VMF_CHILDREN_INDICES;
}
@Override
public Object _vmf_getPropertyValueById(int propertyId) {
switch(propertyId) {
case 0:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getAlternatives();
case 1:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getId();
case 2:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return isLexerRule();
case 3:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return isListType();
case 4:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getName();
case 5:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return isNegated();
case 6:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getParentAlt();
case 7:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return isParserRule();
case 8:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getRuleName();
case 9:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return isTerminal();
case 10:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getText();
}
return null;
}
@Override
public int _vmf_getPropertyIdByName(String propertyName) {
switch(propertyName) {
case "alternatives":
return 0;
case "id":
return 1;
case "lexerRule":
return 2;
case "listType":
return 3;
case "name":
return 4;
case "negated":
return 5;
case "parentAlt":
return 6;
case "parserRule":
return 7;
case "ruleName":
return 8;
case "terminal":
return 9;
case "text":
return 10;
default:
return -1;
} // end switch
}
@Override
public Object _vmf_getDefaultValueById(int propertyId) {
switch(propertyId) {
case 0:
Object __vmf_default_value_tmpAlternatives = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpAlternatives==null) {
return null;
} else {
return __vmf_default_value_tmpAlternatives;
}
case 1:
Object __vmf_default_value_tmpId = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpId==null) {
return
0;
} else {
return __vmf_default_value_tmpId;
}
case 2:
Object __vmf_default_value_tmpLexerRule = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpLexerRule==null) {
return
false;
} else {
return __vmf_default_value_tmpLexerRule;
}
case 3:
Object __vmf_default_value_tmpListType = _VMF_DEFAULT_VALUES[1];
if(__vmf_default_value_tmpListType==null) {
return
false;
} else {
return __vmf_default_value_tmpListType;
}
case 4:
Object __vmf_default_value_tmpName = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpName==null) {
return null;
} else {
return __vmf_default_value_tmpName;
}
case 5:
Object __vmf_default_value_tmpNegated = _VMF_DEFAULT_VALUES[2];
if(__vmf_default_value_tmpNegated==null) {
return
false;
} else {
return __vmf_default_value_tmpNegated;
}
case 6:
Object __vmf_default_value_tmpParentAlt = _VMF_DEFAULT_VALUES[3];
if(__vmf_default_value_tmpParentAlt==null) {
return null;
} else {
return __vmf_default_value_tmpParentAlt;
}
case 7:
Object __vmf_default_value_tmpParserRule = _VMF_DEFAULT_VALUES[4];
if(__vmf_default_value_tmpParserRule==null) {
return
false;
} else {
return __vmf_default_value_tmpParserRule;
}
case 8:
Object __vmf_default_value_tmpRuleName = _VMF_DEFAULT_VALUES[5];
if(__vmf_default_value_tmpRuleName==null) {
return null;
} else {
return __vmf_default_value_tmpRuleName;
}
case 9:
Object __vmf_default_value_tmpTerminal = _VMF_DEFAULT_VALUES[6];
if(__vmf_default_value_tmpTerminal==null) {
return
false;
} else {
return __vmf_default_value_tmpTerminal;
}
case 10:
Object __vmf_default_value_tmpText = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpText==null) {
return null;
} else {
return __vmf_default_value_tmpText;
}
} // end switch
return null;
}
@Override
public void _vmf_setDefaultValueById(int propertyId, Object defaultValue) {
// property alternatives
if(propertyId == 0) {
throw new RuntimeException("Cannot set default value for property 'alternatives' with id="+propertyId +": property is a containment property and not writable.");
}
// property parentAlt
if(propertyId == 6) {
throw new RuntimeException("Cannot set default value for property 'parentAlt' with id="+propertyId +": property is a containment property and not writable.");
}
}
@Override
public boolean _vmf_isSetById(int propertyId) {
return !java.util.Objects.equals(_vmf_getDefaultValueById(propertyId), _vmf_getPropertyValueById(propertyId));
}
final Object[] _VMF_DEFAULT_VALUES = {
null, // type alternatives (containment type, no defaut value possible)
null, // type id
null, // type lexerRule
null, // type listType
null, // type name
null, // type negated
null, // type parentAlt (containment type, no defaut value possible)
null, // type parserRule
null, // type ruleName
null, // type terminal
null // type text
};
@Override
public boolean _vmf_isReadOnly() {
return true;
}
// --------------------------------------------------------------------
// --- Id related methods
// --------------------------------------------------------------------
// id management is currently not part of VMF (TODO how should we support this?)
// --------------------------------------------------------------------
// --- Reference methods
// --------------------------------------------------------------------
public VList _vmf_referencedBy() { return ((eu.mihosoft.vmf.runtime.core.internal.VObjectInternalModifiable)this.mutableObject)._vmf_referencedBy();}
public VList _vmf_references() { return ((eu.mihosoft.vmf.runtime.core.internal.VObjectInternalModifiable)this.mutableObject)._vmf_references();}
}