com.connectifex.polymer.mdl.shared.generated.types.DmcTypeTemplateStringMV Maven / Gradle / Ivy
// Copyright 2020 connectifex
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package com.connectifex.polymer.mdl.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 com.connectifex.polymer.mdl.shared.types.TemplateString; // base type import
import com.connectifex.polymer.mdl.shared.types.DmcTypeTemplateString; // DmcType import
/**
* The DmcTypeTemplateStringMV provides storage for a multi-valued TemplateString
*
* 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:101)
*/
@SuppressWarnings("serial")
public class DmcTypeTemplateStringMV extends DmcTypeTemplateString implements Serializable {
private final static Iterator emptyList = (new ArrayList()).iterator();
protected ArrayList value;
public DmcTypeTemplateStringMV(){
}
public DmcTypeTemplateStringMV(DmcAttributeInfo ai){
super(ai);
}
@Override
public DmcTypeTemplateStringMV getNew(){
return(new DmcTypeTemplateStringMV(getAttributeInfo()));
}
@Override
// org.dmd.dms.util.GenUtility.dumpMVType(GenUtility.java:2546)
public DmcAttribute cloneIt(){
synchronized(this){
DmcTypeTemplateStringMV rc = getNew();
if (value == null)
return(rc);
if (getAttributeInfo().indexSize == 0){
for(TemplateString 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 TemplateString del(Object v){
synchronized(this){
if (value == null)
return(null);
TemplateString key = null;
TemplateString 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 TemplateString 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 TemplateString 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));
TemplateString rc = null;
if (v != null)
rc = typeCheck(v);
if (value == null){
value = new ArrayList(getAttributeInfo().indexSize);
for(int i=0;i