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

com.connectifex.polymer.mdl.shared.generated.types.DmcTypeExpectedGroupValueSET 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.Set;
import java.util.HashSet;
import java.util.TreeSet;
import java.util.Iterator;
import org.dmd.dmc.DmcAttribute;
import org.dmd.dmc.DmcAttributeInfo;
import org.dmd.dmc.DmcValueException;
import org.dmd.dms.generated.enums.ValueTypeEnum;
import com.connectifex.polymer.mdl.shared.generated.types.ExpectedGroupValue;    // base type import
import com.connectifex.polymer.mdl.shared.generated.types.DmcTypeExpectedGroupValue;    // DmcType import
/**
 * The DmcTypeExpectedGroupValueSET provides storage for a set of ExpectedGroupValue
 * 

* This code was auto-generated and shouldn't be altered manually! * Generated from: org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2811) * Called from: org.dmd.dms.util.DmoTypeFormatter.dumpTypes(DmoTypeFormatter.java:127) */ @SuppressWarnings("serial") public class DmcTypeExpectedGroupValueSET extends DmcTypeExpectedGroupValue implements Serializable { private final static Iterator emptyList = (new HashSet()).iterator(); protected Set value; public DmcTypeExpectedGroupValueSET(){ value = null; } public DmcTypeExpectedGroupValueSET(DmcAttributeInfo ai){ super(ai); initValue(); } void initValue(){ if (getAttributeInfo().valueType == ValueTypeEnum.HASHSET) value = new HashSet(); else value = new TreeSet(); } @Override public DmcTypeExpectedGroupValueSET getNew(){ return(new DmcTypeExpectedGroupValueSET(getAttributeInfo())); } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2852) public DmcAttribute cloneIt(){ synchronized(this){ DmcTypeExpectedGroupValueSET rc = getNew(); if (value == null) return(rc); for(ExpectedGroupValue val: value) try { rc.add(val); } catch (DmcValueException e) { throw(new IllegalStateException("typeCheck() should never fail here!",e)); } return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2875) public ExpectedGroupValue add(Object v) throws DmcValueException { synchronized(this){ ExpectedGroupValue rc = typeCheck(v); if (value == null) initValue(); // If false is returned, we didn't modify the set, so return null if (!value.add(rc)) rc = null; return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2892) public ExpectedGroupValue del(Object v){ synchronized(this){ ExpectedGroupValue rc = null; if (value == null) return(rc); try { rc = typeCheck(v); } catch (DmcValueException e) { throw(new IllegalStateException("Incompatible type passed to del():" + getName(),e)); } if (value.contains(rc)){ value.remove(rc); if (value.size() == 0) value = null; } else rc = null; return(rc); } } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2917) public Iterator getMV(){ synchronized(this){ if (value == null) return(emptyList); if (getAttributeInfo().valueType == ValueTypeEnum.HASHSET) return( (new HashSet(value)).iterator() ); else return( (new TreeSet(value)).iterator() ); } } // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2931) public Set getMVCopy(){ synchronized(this){ if (getAttributeInfo().valueType == ValueTypeEnum.HASHSET){ if (value == null) return(new HashSet()); else return(new HashSet(value)); } else{ if (value == null) return(new TreeSet(value)); else return(new TreeSet(value)); } } } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2951) public int getMVSize(){ synchronized(this){ if (value == null) return(0); return(value.size()); } } @Override // org.dmd.dms.util.GenUtility.dumpSETType(GenUtility.java:2962) public boolean contains(Object v){ synchronized(this){ if (value == null) return(false); try { ExpectedGroupValue val = typeCheck(v); return(value.contains(val)); } catch (DmcValueException e) { return(false); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy