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

org.dmd.dmt.dsd.dsda.shared.generated.types.DmcTypeTypeAndAttributeMV 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) 2013-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.dmt.dsd.dsda.shared.generated.types;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import org.dmd.dmc.DmcAttribute;
import org.dmd.dmc.DmcAttributeInfo;
import org.dmd.dmc.DmcValueException;
import org.dmd.dmt.dsd.dsda.shared.generated.types.TypeAndAttribute;    // base type import
import org.dmd.dmt.dsd.dsda.shared.generated.types.DmcTypeTypeAndAttribute;    // DmcType import
/**
 * The DmcTypeTypeAndAttributeMV provides storage for a multi-valued TypeAndAttribute
 * 

* This code was auto-generated and shouldn't be altered manually! * Generated from: org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2515) * Called from: org.dmd.dms.util.DmoTypeFormatter.dumpTypes(DmoTypeFormatter.java:126) */ @SuppressWarnings("serial") public class DmcTypeTypeAndAttributeMV extends DmcTypeTypeAndAttribute implements Serializable { private final static Iterator emptyList = (new ArrayList()).iterator(); protected ArrayList value; public DmcTypeTypeAndAttributeMV(){ } public DmcTypeTypeAndAttributeMV(DmcAttributeInfo ai){ super(ai); } @Override public DmcTypeTypeAndAttributeMV getNew(){ return(new DmcTypeTypeAndAttributeMV(getAttributeInfo())); } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2546) public DmcAttribute cloneIt(){ synchronized(this){ DmcTypeTypeAndAttributeMV rc = getNew(); if (value == null) return(rc); if (getAttributeInfo().indexSize == 0){ for(TypeAndAttribute val: value) try { rc.add(val); } catch (DmcValueException e) { throw(new IllegalStateException("typeCheck() should never fail here!",e)); } } else{ for(int index=0; index(); value.add(rc); return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2592) public TypeAndAttribute del(Object v){ synchronized(this){ if (value == null) return(null); TypeAndAttribute key = null; TypeAndAttribute rc = null; try { key = typeCheck(v); } catch (DmcValueException e) { throw(new IllegalStateException("Incompatible type passed to del():" + getName(),e)); } int indexof = value.indexOf(key); if (indexof != -1){ rc = value.get(indexof); value.remove(rc); } return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2626) public Iterator getMV(){ synchronized(this){ if (value == null) return(emptyList); ArrayList clone = new ArrayList(value); return(clone.iterator()); } } // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2638) public ArrayList getMVCopy(){ synchronized(this){ if (value == null) return(new ArrayList()); else return(new ArrayList(value)); } } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2650) public int getMVSize(){ synchronized(this){ if (getAttributeInfo().indexSize == 0){ if (value == null) return(0); return(value.size()); } else return(getAttributeInfo().indexSize); } } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2665) public TypeAndAttribute getMVnth(int index){ synchronized(this){ if (value == null) return(null); return(value.get(index)); } } @Override // org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2676) public TypeAndAttribute setMVnth(int index, Object v) throws DmcValueException { synchronized(this){ if (getAttributeInfo().indexSize == 0) throw(new IllegalStateException("Attribute: " + getAttributeInfo().name + " is not indexed. You can't use setMVnth().")); if ( (index < 0) || (index >= getAttributeInfo().indexSize)) throw(new IllegalStateException("Index " + index + " for attribute: " + getAttributeInfo().name + " is out of range: 0 <= index < " + getAttributeInfo().indexSize)); TypeAndAttribute rc = null; if (v != null) rc = typeCheck(v); if (value == null){ value = new ArrayList(getAttributeInfo().indexSize); for(int i=0;i





© 2015 - 2024 Weber Informatics LLC | Privacy Policy