SCViewer/com.minres.scviewer.databas.../src/com/minres/scviewer/database/text/TxAttributeTypeFactory.groovy

39 lines
1.3 KiB
Groovy
Raw Normal View History

2012-06-17 20:34:50 +02:00
/*******************************************************************************
* Copyright (c) 2012 IT Just working.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IT Just working - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.text
2012-06-17 19:53:05 +02:00
import com.minres.scviewer.database.AssociationType;
import com.minres.scviewer.database.DataType
2015-01-06 17:14:16 +01:00
import com.minres.scviewer.database.ITxAttributeType
import com.minres.scviewer.database.ITxAttribute
2012-06-17 19:53:05 +02:00
2015-01-06 17:14:16 +01:00
class TxAttributeTypeFactory {
private static final instance = new TxAttributeTypeFactory()
2012-06-17 19:53:05 +02:00
def attributes = [:]
2015-01-06 17:14:16 +01:00
private TxAttributeTypeFactory() {
TxAttributeTypeFactory.metaClass.constructor = {-> instance }
2012-06-17 19:53:05 +02:00
}
2015-01-06 17:14:16 +01:00
ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
def key = name+":"+dataType.toString()
2015-01-06 17:14:16 +01:00
ITxAttributeType res
2012-06-17 19:53:05 +02:00
if(attributes.containsKey(key)){
res=attributes[key]
} else {
2015-01-06 17:14:16 +01:00
res=new TxAttributeType(name, dataType, type)
2012-06-17 19:53:05 +02:00
attributes[key]=res
}
return res
}
}