All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmd.dmt.shared.generated.types.DmcTypeTestDerivedSubpackageREFMAP Maven / Gradle / Ivy

Go to download

The dark-matter project provides mechanism to define concepts associated with Domain Specific Languages (DSLs) and generate code that can be extended with business logic that supports the given DSL purpose.

There is a newer version: 3.1.15
Show newest version
package org.dmd.dmt.shared.generated.types;

import java.io.Serializable;
import java.util.Map;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Iterator;
import org.dmd.dmc.DmcAttribute;
import org.dmd.dmc.DmcAttributeInfo;
import org.dmd.dmc.DmcValueException;
import org.dmd.dmc.DmcMappedAttributeIF;
import org.dmd.dms.generated.enums.ValueTypeEnum;
import org.dmd.dmc.types.DefinitionName;    // key type import
/**
 * The DmcTypeTestDerivedSubpackageREFMAP provides storage for a map of TestDerivedSubpackageREF
 * 

* This code was auto-generated and shouldn't be altered manually! * Generated from: org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3044) * Called from: org.dmd.dms.util.DmoTypeFormatter.dumpNamedREF(DmoTypeFormatter.java:544) */ @SuppressWarnings("serial") // public class DmcTypeTestDerivedSubpackageREFMAP extends DmcTypeTestDerivedSubpackageREF { public class DmcTypeTestDerivedSubpackageREFMAP extends DmcTypeTestDerivedSubpackageREF implements Serializable { private final static Iterator emptyList = (new HashMap()).values().iterator(); protected Map value; public DmcTypeTestDerivedSubpackageREFMAP(){ value = null; } public DmcTypeTestDerivedSubpackageREFMAP(DmcAttributeInfo ai){ super(ai); initValue(); } void initValue(){ if (getAttributeInfo().valueType == ValueTypeEnum.HASHMAPPED) value = new HashMap(); else value = new TreeMap(); } public DefinitionName firstKey(){ if (getAttributeInfo().valueType == ValueTypeEnum.TREEMAPPED){ if (value == null) return(null); TreeMap map = (TreeMap)value; return(map.firstKey()); } throw(new IllegalStateException("Attribute " + getAttributeInfo().name + " is HASHMAPPED and doesn't support firstKey()")); } @Override public DmcTypeTestDerivedSubpackageREFMAP getNew(){ return(new DmcTypeTestDerivedSubpackageREFMAP(getAttributeInfo())); } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3101) public DmcAttribute cloneIt(){ synchronized(this){ DmcTypeTestDerivedSubpackageREFMAP rc = getNew(); if (value == null) return(rc); for(TestDerivedSubpackageREF val: value.values()) try { rc.add(val); } catch (DmcValueException e) { throw(new IllegalStateException("typeCheck() should never fail here!",e)); } return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3121) public TestDerivedSubpackageREF add(Object v) throws DmcValueException { synchronized(this){ TestDerivedSubpackageREF newval = typeCheck(v); if (value == null) initValue(); DefinitionName key = (DefinitionName)((DmcMappedAttributeIF)newval).getKey(); TestDerivedSubpackageREF oldval = value.put(key,newval); if (oldval != null){ // We had a value with this key, ensure that the value actually changed if (oldval.valuesAreEqual(newval)) newval = null; } return(newval); } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3142) public TestDerivedSubpackageREF del(Object key){ synchronized(this){ if (value == null) return(null); if (key instanceof DefinitionName) return(value.remove(key)); else throw(new IllegalStateException("Incompatible key type: " + key.getClass().getName() + " passed to del():" + getName())); } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3158) public Iterator getMV(){ synchronized(this){ if (value == null) return(emptyList); Map clone = null; if (getAttributeInfo().valueType == ValueTypeEnum.HASHMAPPED) clone = new HashMap(value); else clone = new TreeMap(value); return(clone.values().iterator()); } } // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3175) public Map getMVCopy(){ synchronized(this){ Map clone = null; if (getAttributeInfo().valueType == ValueTypeEnum.HASHMAPPED){ if (value == null) clone = new HashMap(); else clone = new HashMap(value); } else{ if (value == null) clone = new TreeMap(); else clone = new TreeMap(value); } return(clone); } } // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3196) @Override public int getMVSize(){ synchronized(this){ if (value == null) return(0); return(value.size()); } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3208) public TestDerivedSubpackageREF getByKey(Object key){ synchronized(this){ if (value == null) return(null); if (key instanceof DefinitionName) return(value.get((DefinitionName) key)); else throw(new IllegalStateException("Incompatible type: " + key.getClass().getName() + " passed to del():" + getName())); } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3223) public boolean contains(Object v){ synchronized(this){ if (value == null) return(false); try { TestDerivedSubpackageREF val = typeCheck(v); return(value.containsValue(val)); } catch (DmcValueException e) { return(false); } } } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3240) public boolean containsKey(Object key){ synchronized(this){ if (value == null) return(false); if (key instanceof DefinitionName) return(value.containsKey(key)); return(false); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy