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.ReadOnlyMappingImpl 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
// interface
/**
* An read-only representation of the model object {@code eu.mihosoft.vmf.vmftext.grammar.Mapping}.
*/
@SuppressWarnings("deprecation")
class ReadOnlyMappingImpl implements ReadOnlyMapping, eu.mihosoft.vmf.runtime.core.internal.VObjectInternal, VCloneableInternal {
private final Mapping mutableObject;
// Read-only view for collection properties
// - properties with collection type (model & non-model collections)
// - we don't allow/provide setters for collection properties
public ReadOnlyMappingImpl(Mapping mutableObject) {
this.mutableObject = mutableObject;
}
@Override
public java.lang.String getDefaultValueCode() {
return this.mutableObject.getDefaultValueCode();
}
@Override
// property type is a model-type
public ReadOnlyTypeMapping getParent() {
if(this.mutableObject.getParent()!=null) {
return this.mutableObject.getParent().asReadOnly();
} else {
return null;
}
}
@Override
public java.lang.String getRuleName() {
return this.mutableObject.getRuleName();
}
@Override
public java.lang.String getStringToTypeCode() {
return this.mutableObject.getStringToTypeCode();
}
@Override
public java.lang.String getTypeName() {
return this.mutableObject.getTypeName();
}
@Override
public java.lang.String getTypeToStringCode() {
return this.mutableObject.getTypeToStringCode();
}
// 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 Mapping _vmf_getMutableObject() {
return this.mutableObject;
}
@Override
public ReadOnlyMappingImpl asReadOnly() {
return this;
}
// --------------------------------------------------------------------
// --- Cloning
// --------------------------------------------------------------------
@Override
public ReadOnlyMapping clone() {
return this.mutableObject.clone().asReadOnly();
}
@Override
public Mapping asModifiable() {
return this.mutableObject.clone();
}
@Override
public Mapping _vmf_deepCopy(
java.util.IdentityHashMap identityMap) {
return (Mapping)
((VCloneableInternal)this.mutableObject)._vmf_deepCopy(
new java.util.IdentityHashMap<>());
}
@Override
public ReadOnlyMapping _vmf_shallowCopy(
java.util.IdentityHashMap identityMap) {
return (ReadOnlyMapping)
((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(ReadOnlyMappingImpl.this);
}
public java.util.stream.Stream stream() {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyMappingImpl.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(ReadOnlyMappingImpl.this, strategy);
}
public java.util.stream.Stream stream(eu.mihosoft.vmf.runtime.core.VIterator.IterationStrategy strategy) {
return eu.mihosoft.vmf.runtime.core.VIterator.of(ReadOnlyMappingImpl.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 ReadOnlyMapping deepCopy() {
return (ReadOnlyMappingImpl)
((VCloneableInternal)ReadOnlyMappingImpl.this.mutableObject)._vmf_deepCopy(
new java.util.IdentityHashMap<>()).asReadOnly();
}
@Override
public ReadOnlyMapping shallowCopy() {
return ReadOnlyMappingImpl.
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(ReadOnlyMappingImpl.this);
}
return reflect;
}
}; // end vmf
}
// --------------------------------------------------------------------
// --- Reflection methods
// --------------------------------------------------------------------
// type id for improved reflection performance
public static final int _VMF_TYPE_ID = 21;
@Override
public int _vmf_getTypeId() {
return _VMF_TYPE_ID;
}
static final String[] _VMF_PROPERTY_NAMES = {
"defaultValueCode",
"parent",
"ruleName",
"stringToTypeCode",
"typeName",
"typeToStringCode"
};
static final String[] _VMF_PROPERTY_TYPE_NAMES = {
"java.lang.String", // type id -1
"eu.mihosoft.vmf.vmftext.grammar.TypeMapping", // type id 34
"java.lang.String", // type id -1
"java.lang.String", // type id -1
"java.lang.String", // type id -1
"java.lang.String" // type id -1
};
static final int[] _VMF_PROPERTY_TYPES = {
-1, // type java.lang.String
34, // type eu.mihosoft.vmf.vmftext.grammar.TypeMapping
-1, // type java.lang.String
-1, // type java.lang.String
-1, // type java.lang.String
-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 = {
};
/**
* - 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 = {
};
/**
* - 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 = {
};
@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 getDefaultValueCode();
case 1:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getParent();
case 2:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getRuleName();
case 3:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getStringToTypeCode();
case 4:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getTypeName();
case 5:
// TODO check whether we can prevent lazy initialized properties from
// being initialized just for iterating the object graph
return getTypeToStringCode();
}
return null;
}
@Override
public int _vmf_getPropertyIdByName(String propertyName) {
switch(propertyName) {
case "defaultValueCode":
return 0;
case "parent":
return 1;
case "ruleName":
return 2;
case "stringToTypeCode":
return 3;
case "typeName":
return 4;
case "typeToStringCode":
return 5;
default:
return -1;
} // end switch
}
@Override
public Object _vmf_getDefaultValueById(int propertyId) {
switch(propertyId) {
case 0:
Object __vmf_default_value_tmpDefaultValueCode = _VMF_DEFAULT_VALUES[0];
if(__vmf_default_value_tmpDefaultValueCode==null) {
return null;
} else {
return __vmf_default_value_tmpDefaultValueCode;
}
case 1:
Object __vmf_default_value_tmpParent = _VMF_DEFAULT_VALUES[1];
if(__vmf_default_value_tmpParent==null) {
return null;
} else {
return __vmf_default_value_tmpParent;
}
case 2:
Object __vmf_default_value_tmpRuleName = _VMF_DEFAULT_VALUES[2];
if(__vmf_default_value_tmpRuleName==null) {
return null;
} else {
return __vmf_default_value_tmpRuleName;
}
case 3:
Object __vmf_default_value_tmpStringToTypeCode = _VMF_DEFAULT_VALUES[3];
if(__vmf_default_value_tmpStringToTypeCode==null) {
return null;
} else {
return __vmf_default_value_tmpStringToTypeCode;
}
case 4:
Object __vmf_default_value_tmpTypeName = _VMF_DEFAULT_VALUES[4];
if(__vmf_default_value_tmpTypeName==null) {
return null;
} else {
return __vmf_default_value_tmpTypeName;
}
case 5:
Object __vmf_default_value_tmpTypeToStringCode = _VMF_DEFAULT_VALUES[5];
if(__vmf_default_value_tmpTypeToStringCode==null) {
return null;
} else {
return __vmf_default_value_tmpTypeToStringCode;
}
} // end switch
return null;
}
@Override
public void _vmf_setDefaultValueById(int propertyId, Object defaultValue) {
// property parent
if(propertyId == 1) {
throw new RuntimeException("Cannot set default value for property 'parent' 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 defaultValueCode
null, // type parent (containment type, no defaut value possible)
null, // type ruleName
null, // type stringToTypeCode
null, // type typeName
null // type typeToStringCode
};
@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();}
}