当前位置: 首页>>代码示例>>Java>>正文


Java GenClass类代码示例

本文整理汇总了Java中org.eclipse.emf.codegen.ecore.genmodel.GenClass的典型用法代码示例。如果您正苦于以下问题:Java GenClass类的具体用法?Java GenClass怎么用?Java GenClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenClass类属于org.eclipse.emf.codegen.ecore.genmodel包,在下文中一共展示了GenClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getGenFeature

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public static GenFeature getGenFeature(final EStructuralFeature feature, final ResourceSet resourceSet) {
  GenClassifier _genClassifier = GenModelUtil2.getGenClassifier(feature.getEContainingClass(), resourceSet);
  final GenClass genCls = ((GenClass) _genClassifier);
  EList<GenFeature> _genFeatures = genCls.getGenFeatures();
  for (final GenFeature genFeat : _genFeatures) {
    String _name = feature.getName();
    String _name_1 = genFeat.getEcoreFeature().getName();
    boolean _equals = Objects.equal(_name, _name_1);
    if (_equals) {
      return genFeat;
    }
  }
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("No GenFeature named \'");
  String _name_2 = feature.getName();
  _builder.append(_name_2);
  _builder.append("\' found in GenClass \'");
  _builder.append(genCls);
  _builder.append("\' from GenModel");
  URI _uRI = genCls.eResource().getURI();
  _builder.append(_uRI);
  throw new RuntimeException(_builder.toString());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:GenModelUtil2.java

示例2: getGetAccessor

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public static String getGetAccessor(final GenFeature genFeature, final ResourceSet resourceSet) {
  final GenClass genClass = genFeature.getGenClass();
  boolean _isMapEntry = genClass.isMapEntry();
  if (_isMapEntry) {
    GenFeature _mapEntryKeyFeature = genClass.getMapEntryKeyFeature();
    boolean _equals = Objects.equal(genFeature, _mapEntryKeyFeature);
    if (_equals) {
      return "getKey";
    }
    GenFeature _mapEntryValueFeature = genClass.getMapEntryValueFeature();
    boolean _equals_1 = Objects.equal(genFeature, _mapEntryValueFeature);
    if (_equals_1) {
      return "getValue";
    }
  }
  return genFeature.getGetAccessor();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:GenModelUtil2.java

示例3: testClassNames

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
@Test
public void testClassNames()
{
	GenModel gm = getGenModel(PROJECT_GENMODEL);
	GenerateDevStructure gen = getGenDevStructure(PROJECT_GENMODEL);
	
	GenClass gc = findGenClass(gm, "Project");
	// Check interface and class names
	assertEquals("The dev interface name must be Project", "Project", gen.computeInterfaceName(gc));
	assertEquals("The dev class  name must be ProjectImpl", "ProjectImpl", gen.computeClassname(gc));
	assertEquals("The gen interface  name must be MProject", "MProject", gen.computeGeneratedInterfaceName(gc));
	assertEquals("The gen class  name must be MProjectImpl", "MProjectImpl", gen.computeGeneratedClassName(gc));

	// Check for packages names
	GenPackage gp = findGenPackage(gm, "project");
	assertEquals("The dev factory interface  name must be ProjectFactory", "ProjectFactory",
			gen.computeFactoryInterfaceName(gp));
	assertEquals("The dev factory class  name must be ProjectFactoryImpl", "ProjectFactoryImpl",
			gen.computeFactoryClassName(gp));
	assertEquals("The gen factory interface  name must be MProjectFactory", "MProjectFactory",
			gp.getFactoryInterfaceName());
	assertEquals("The gen factory class  name must be MProjectFactoryImpl", "MProjectFactoryImpl",
			gp.getFactoryClassName());
}
 
开发者ID:opcoach,项目名称:genModelAddon,代码行数:25,代码来源:TestClassNames.java

示例4: classWithMapInstanceNameMustNotBeGenerated

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
@Test
public void classWithMapInstanceNameMustNotBeGenerated()
{
	GenModel gm = getGenModel(PROJECT_GENMODEL);
	// Check EClass IntToDoubleMap exists. 
	GenClass gc = findGenClass(gm, "IntToDoubleMap");
	EClass c = (gc == null) ? null : gc.getEcoreClass();
	
	assertNotNull("The EClass IntToDoubleMap is present in test model", c);
	assertTrue("The IntToDoubleMap instance type name must be java.util.Map$Entry", GenerateCommon.isMapType(c));
	
	// Now the file for this class must not be generated...
	assertFileNotExists("src/com/opcoach/project/IntToDoubleMap.java");
	assertFileNotExists("src/com/opcoach/project/impl/IntToDoubleMapImpl.java");
	
	// Check that factory generated file does not contain the IntToDoubleMap class
	assertFileDoesNotContain("src/com/opcoach/project/ProjectFactory.java", "IntToDoubleMap");
	assertFileDoesNotContain("src/com/opcoach/project/impl/ProjectFactoryImpl.java", "IntToDoubleMap");

}
 
开发者ID:opcoach,项目名称:genModelAddon,代码行数:21,代码来源:TestInterfaceGeneration.java

示例5: getGenFeature

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public static GenFeature getGenFeature(EStructuralFeature feature, ResourceSet resourceSet) {
	GenClass genCls = (GenClass) getGenClassifier(feature.getEContainingClass(), resourceSet);
	for (GenFeature genFeat : genCls.getGenFeatures())
		if (feature.getName().equals(genFeat.getEcoreFeature().getName())) {
			return genFeat;
		}
	throw new RuntimeException("No GenFeature named '" + feature.getName() + "' found in GenClass '" + genCls
			+ "' from GenModel" + genCls.eResource().getURI());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:GenModelAccess.java

示例6: getJavaTypeName

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
/**
 * @since 2.1
 */
public static String getJavaTypeName(EClassifier classifier, ResourceSet resourceSet) {
	GenClassifier genClassifier = getGenClassifier(classifier, resourceSet);
	if (genClassifier instanceof GenClass) {
		return ((GenClass) genClassifier).getQualifiedInterfaceName();
	} else {
		return ((GenDataType) genClassifier).getQualifiedInstanceClassName();
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:GenModelAccess.java

示例7: getGetAccessor

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public String getGetAccessor(EStructuralFeature feature) {
	GenFeature genFeature = GenModelAccess.getGenFeature(feature, resourceSet);
	GenClass genClass = genFeature.getGenClass();
	if (genClass.isMapEntry()) {
		if (genFeature == genClass.getMapEntryKeyFeature())
			return "getKey";
		if (genFeature == genClass.getMapEntryValueFeature())
			return "getValue";
	}
	return genFeature.getGetAccessor();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:JavaEMFFile.java

示例8: importedGenTypeName

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public String importedGenTypeName(EClass clazz) {
	GenClass gc = GenModelAccess.getGenClass(clazz, resourceSet);
	if (gc.isMapEntry()) {
		String entryType = imported(BasicEMap.Entry.class);
		return entryType + "<?, ?>";
	}
	return imported(gc.getQualifiedInterfaceName());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:JavaEMFFile.java

示例9: getJavaTypeName

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public static String getJavaTypeName(final EClassifier classifier, final ResourceSet resourceSet) {
  final GenClassifier genClassifier = GenModelUtil2.getGenClassifier(classifier, resourceSet);
  if ((genClassifier instanceof GenClass)) {
    return ((GenClass)genClassifier).getQualifiedInterfaceName();
  } else {
    return ((GenDataType) genClassifier).getQualifiedInstanceClassName();
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:9,代码来源:GenModelUtil2.java

示例10: produceCodeFor

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
/**
 * this class produce the HLAPI class for the given genClass.
 *
 * @param gCl
 *            the genclass from which produce code.
 */
public final void produceCodeFor(final GenClass gCl) {
    final HLAPI hlapi = new HLAPI();
    final String code = hlapi.generate(gCl);
    log.info("Generating " + gCl.getName() + " HLAPI class code");
    // Be careful the folder tree must exists
    final String path;
    path = gCl.getGenPackage().getInterfacePackageName().replace(".", "/")
            + "/hlapi";

    // creates folder tree
    if (new File(getOutputfolder() + "/" + path).mkdirs()) {
        log.info("packages folders created");
    }

    final File myfile = new File(getOutputfolder() + "/" + path + "/"
            + gCl.getInterfaceName() + HLAPI_CLASSES_EXT + ".java");
    try {
        final Writer output = new BufferedWriter(new FileWriter(myfile));
        output.write(code);
        output.close();
    } catch (IOException e) {
        log
                .error(
                        "The java file cannot be write, have you check if the folder tree exists?",
                        e);
    }

}
 
开发者ID:lip6,项目名称:pnmlframework,代码行数:35,代码来源:GenerateHLAPI.java

示例11: produceTestCodeFor

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
/**
 * this class produce the HLAPI class for the given genClass.
 *
 * @param gCl
 *            the genclass from which produce code.
 */
public final void produceTestCodeFor(final GenClass gCl) {
    final HLAPITests hlapi = new HLAPITests();
    final String code = hlapi.generate(gCl);
    log.info("Generating " + gCl.getName() + " HLAPI Test class code");
    // Be careful the folder tree must exists
    final String path;
    path = gCl.getGenPackage().getInterfacePackageName().replace(".", "/")
            + "/hlapi";

    // creates folder tree
    if (new File(getTestoutputfolder() + "/" + path).mkdirs()) {
        log.info("packages folders created");
    }

    final File myfile = new File(getTestoutputfolder() + "/" + path + "/"
            + gCl.getInterfaceName() + HLAPI_TEST_CLASSES_EXT + ".java");
    try {
        final Writer output = new BufferedWriter(new FileWriter(myfile));
        output.write(code);
        output.close();
    } catch (IOException e) {
        log
                .error(
                        "The java file cannot be write, have you check if the folder tree exists?",
                        e);
    }
}
 
开发者ID:lip6,项目名称:pnmlframework,代码行数:34,代码来源:GenerateHLAPI.java

示例12: generateClassContent

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public CharSequence generateClassContent(final GenClass gc) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append(this.copyright);
  _builder.newLineIfNotEmpty();
  _builder.append("package ");
  String _computePackageNameForClasses = this.computePackageNameForClasses(gc.getGenPackage());
  _builder.append(_computePackageNameForClasses);
  _builder.append(";");
  _builder.newLineIfNotEmpty();
  _builder.newLine();
  _builder.append("import ");
  String _computePackageNameForInterfaces = this.computePackageNameForInterfaces(gc.getGenPackage());
  _builder.append(_computePackageNameForInterfaces);
  _builder.append(".");
  String _computeInterfaceFilename = this.computeInterfaceFilename(gc);
  _builder.append(_computeInterfaceFilename);
  _builder.append(";");
  _builder.newLineIfNotEmpty();
  _builder.newLine();
  _builder.append("// This class overrides the generated class and will be instantiated by factory");
  _builder.newLine();
  _builder.append("public class ");
  String _computeClassname = this.computeClassname(gc);
  _builder.append(_computeClassname);
  _builder.append(" extends ");
  String _computeGeneratedClassName = this.computeGeneratedClassName(gc);
  _builder.append(_computeGeneratedClassName);
  _builder.append(" implements ");
  String _computeInterfaceName = this.computeInterfaceName(gc);
  _builder.append(_computeInterfaceName);
  _builder.newLineIfNotEmpty();
  _builder.append("{");
  _builder.newLine();
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  return _builder;
}
 
开发者ID:opcoach,项目名称:genModelAddon,代码行数:39,代码来源:GenerateDevStructure.java

示例13: generateFactoryDef

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
public CharSequence generateFactoryDef(final GenClass gc) {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("public ");
  String _extractGenericTypes = this.extractGenericTypes(this.computeInterfaceName(gc));
  _builder.append(_extractGenericTypes);
  String _computeInterfaceName = this.computeInterfaceName(gc);
  _builder.append(_computeInterfaceName);
  _builder.append(" create");
  String _name = gc.getEcoreClass().getName();
  _builder.append(_name);
  _builder.append("();");
  _builder.newLineIfNotEmpty();
  return _builder;
}
 
开发者ID:opcoach,项目名称:genModelAddon,代码行数:15,代码来源:GenerateDevStructure.java

示例14: findGenClassInGenPackageList

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
GenClass findGenClassInGenPackageList(Collection<GenPackage> packages, String name)
{
	for (GenPackage gp : packages)
	{
		for (GenClass gc : gp.getGenClasses())
			if (name.equals(gc.getEcoreClass().getName()))
				return gc;

		GenClass subResult = findGenClassInGenPackageList(gp.getSubGenPackages(), name);
		if (subResult != null)
			return subResult;
	}
	return null;
}
 
开发者ID:opcoach,项目名称:genModelAddon,代码行数:15,代码来源:GenModelAddonTestCase.java

示例15: generateModel

import org.eclipse.emf.codegen.ecore.genmodel.GenClass; //导入依赖的package包/类
@Override
protected Diagnostic generateModel(Object object, Monitor monitor)
{
  GenClass genClass = (GenClass)object;
  GenPackage genPackage = genClass.getGenPackage();

  monitor.beginTask("", 2);
  monitor.subTask(message);

  GenModel genModel = genClass.getGenModel();
  ensureProjectExists
    (genModel.getModelDirectory(), genClass, MODEL_PROJECT_TYPE, genModel.isUpdateClasspath(), createMonitor(monitor, 1));


  
  generateJava
  (genModel.getModelDirectory(),
  		genPackage.getInterfacePackageName() + ".proxy", 
  		genClass.getInterfaceName()+"Proxy",
  		
   getJETEmitter(getJETEmitterDescriptors(), REF_ID),
   null,
   createMonitor(monitor, 1)); 
  
  generateJava
  (genModel.getModelDirectory(),
  		genPackage.getInterfacePackageName() + ".proxy", 
  		genClass.getInterfaceName()+"Adapter",
  		
   getJETEmitter(getJETEmitterDescriptors(), ADAPTER_ID),
   null,
   createMonitor(monitor, 1)); 

  return Diagnostic.OK_INSTANCE;
}
 
开发者ID:SOM-Research,项目名称:emf-rest,代码行数:36,代码来源:GenClassEMFRestGeneratorAdapter.java


注:本文中的org.eclipse.emf.codegen.ecore.genmodel.GenClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。