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

org.dmd.dms.generated.types.DmcTypeIntegerToUUIDLiteMAP 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
//	---------------------------------------------------------------------------
//	dark-matter-data
//	Copyright (c) 2012-2021 dark-matter-data committers
//	---------------------------------------------------------------------------
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU Lesser General Public License as published by the
//	Free Software Foundation; either version 3 of the License, or (at your
//	option) any later version.
//	This program is distributed in the hope that it will be useful, but WITHOUT
//	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
//	more details.
//	You should have received a copy of the GNU Lesser General Public License along
//	with this program; if not, see .
//	---------------------------------------------------------------------------
package org.dmd.dms.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.DmcTypeIntegerToUUIDLite;    // base type import
import org.dmd.dmc.types.IntegerToUUIDLite;    // primitive import
/**
 * The DmcTypeIntegerToUUIDLiteMAP provides storage for a map of IntegerToUUIDLite
 * 

* 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.meta.MetaGenerator.dumpDerivedTypes(MetaGenerator.java:679) */ @SuppressWarnings("serial") // public class DmcTypeIntegerToUUIDLiteMAP extends DmcTypeIntegerToUUIDLite { public class DmcTypeIntegerToUUIDLiteMAP extends DmcTypeIntegerToUUIDLite implements Serializable { private final static Iterator emptyList = (new HashMap()).values().iterator(); protected Map value; public DmcTypeIntegerToUUIDLiteMAP(){ value = null; } public DmcTypeIntegerToUUIDLiteMAP(DmcAttributeInfo ai){ super(ai); initValue(); } void initValue(){ if (getAttributeInfo().valueType == ValueTypeEnum.HASHMAPPED) value = new HashMap(); else value = new TreeMap(); } public Integer 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 DmcTypeIntegerToUUIDLiteMAP getNew(){ return(new DmcTypeIntegerToUUIDLiteMAP(getAttributeInfo())); } @Override // org.dmd.dms.util.GenUtility.dumpMAPType(GenUtility.java:3101) public DmcAttribute cloneIt(){ synchronized(this){ DmcTypeIntegerToUUIDLiteMAP rc = getNew(); if (value == null) return(rc); for(IntegerToUUIDLite 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 IntegerToUUIDLite add(Object v) throws DmcValueException { synchronized(this){ IntegerToUUIDLite newval = typeCheck(v); if (value == null) initValue(); Integer key = (Integer)((DmcMappedAttributeIF)newval).getKey(); IntegerToUUIDLite 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 IntegerToUUIDLite del(Object key){ synchronized(this){ if (value == null) return(null); if (key instanceof Integer) 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 IntegerToUUIDLite getByKey(Object key){ synchronized(this){ if (value == null) return(null); if (key instanceof Integer) return(value.get((Integer) 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 { IntegerToUUIDLite 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 Integer) return(value.containsKey(key)); return(false); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy