本文整理汇总了Java中org.kie.workbench.common.services.datamodeller.core.DataObject.addNestedClass方法的典型用法代码示例。如果您正苦于以下问题:Java DataObject.addNestedClass方法的具体用法?Java DataObject.addNestedClass怎么用?Java DataObject.addNestedClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kie.workbench.common.services.datamodeller.core.DataObject
的用法示例。
在下文中一共展示了DataObject.addNestedClass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRemoteCallback
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private RemoteCallback<JavaClass> getRemoteCallback(DataObject dataObject,
JavaClass currentComparatorObject) {
return new RemoteCallback<JavaClass>() {
@Override
public void callback(JavaClass updatedComparatorObject) {
dataObject.removeNestedClass(currentComparatorObject);
dataObject.addNestedClass(updatedComparatorObject);
}
};
}
示例2: updateDataObject
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
public void updateDataObject(Path dataObjectPath) {
String dataObjectString = ioService.readAllString(Paths.convert(dataObjectPath));
GenerationResult generationResult = dataModelerService.loadDataObject(dataObjectPath,
dataObjectString,
dataObjectPath);
DataObject dataObject = generationResult.getDataObject();
if (dataObject != null && generationResult.getErrors() == null || generationResult.getErrors().isEmpty()) {
JavaClass comparatorObject = getComparatorObject(dataObject);
if (comparatorObject != null) {
JavaClass updatedComparatorObject = comparatorDefinitionService.updateComparatorObject(dataObject,
comparatorObject);
dataObject.removeNestedClass(comparatorObject);
dataObject.addNestedClass(updatedComparatorObject);
Annotation planningEntityAnnotation = dataObject.getAnnotation(PlanningEntity.class.getName());
if (planningEntityAnnotation != null) {
planningEntityAnnotation.setValue("difficultyComparatorClass",
dataObject.getName() + ".DifficultyComparator");
}
generationResult = dataModelerService.updateSource(dataObjectString,
dataObjectPath,
dataObject);
if (generationResult.getDataObject() != null && generationResult.getErrors() == null || generationResult.getErrors().isEmpty()) {
ioService.write(Paths.convert(dataObjectPath),
generationResult.getSource());
} else {
logger.error("Data object " + dataObject.getClassName() + " couldn't be updated, path: " + dataObjectPath + ".");
}
}
} else {
logger.error("Data object couldn't be loaded, path: " + dataObjectPath + ".");
}
}
示例3: updateComparatorObject
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
@Test
public void updateComparatorObject() {
DataObject dataObject = new DataObjectImpl("foo.bar",
"TestDataObject");
JavaClass comparatorObject = new JavaClassImpl("",
"DifficultyComparator");
Parameter parameter1 = new ParameterImpl(new TypeImpl("TestDataObject"),
"o1");
Parameter parameter2 = new ParameterImpl(new TypeImpl("TestDataObject"),
"o2");
Method compareMethod = new MethodImpl("compare",
Arrays.asList(parameter1,
parameter2),
"foo",
new TypeImpl("int"),
Visibility.PUBLIC);
comparatorObject.addMethod(compareMethod);
comparatorObject.addInterface("java.util.Comparator<foo.bar.TestDataObject>");
dataObject.addNestedClass(comparatorObject);
comparatorObject.addAnnotation(new AnnotationImpl(DriverUtils.buildAnnotationDefinition(ComparatorDefinition.class)));
// Rename data object
dataObject.setName("TestDataObjectUpdated");
JavaClass updatedComparatorObject = comparatorDefinitionService.updateComparatorObject(dataObject,
comparatorObject);
assertTrue(updatedComparatorObject.getInterfaces().contains("java.util.Comparator<foo.bar.TestDataObjectUpdated>"));
}
示例4: createNestedClassUpdateTest
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private DataObject createNestedClassUpdateTest() {
DataObject dataObject = createDataObject("org.kie.workbench.common.services.datamodeller.driver.package5",
"NestedClassUpdateTest",
null);
JavaClass nestedClass = new JavaClassImpl("",
"NestedClass");
nestedClass.addInterface("java.io.Serializable");
nestedClass.addInterface("ParametrizedInterface<Integer>");
Annotation generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value",
Arrays.asList("foo.bar.Generator"));
nestedClass.addAnnotation(generatedAnnotation);
MethodImpl method = new MethodImpl("method",
Collections.EMPTY_LIST,
"",
new TypeImpl(void.class.getName()),
Visibility.PUBLIC);
generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value",
Arrays.asList("foo.bar.Generator"));
method.addAnnotation(generatedAnnotation);
nestedClass.addMethod(method);
dataObject.addNestedClass(nestedClass);
return dataObject;
}
示例5: createNestedClassUpdateTestResult
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private DataObject createNestedClassUpdateTestResult() {
DataObject dataObject = createDataObject("org.kie.workbench.common.services.datamodeller.driver.package5",
"NestedClassUpdateTestResult",
null);
JavaClass nestedClass = new JavaClassImpl("",
"UpdatedNestedClass");
nestedClass.addInterface("java.io.Serializable");
nestedClass.addInterface("ParametrizedInterface<Double>");
Annotation generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value",
Arrays.asList("foo.bar.Generator"));
nestedClass.addAnnotation(generatedAnnotation);
MethodImpl method = new MethodImpl("updatedMethod",
Collections.EMPTY_LIST,
"",
new TypeImpl(void.class.getName()),
Visibility.PUBLIC);
generatedAnnotation = createAnnotation(Generated.class);
generatedAnnotation.setValue("value",
Arrays.asList("foo.bar.Generator"));
method.addAnnotation(generatedAnnotation);
nestedClass.addMethod(method);
dataObject.addNestedClass(nestedClass);
return dataObject;
}
示例6: initDataObjects
import org.kie.workbench.common.services.datamodeller.core.DataObject; //导入方法依赖的package包/类
private void initDataObjects() {
Map<String, AnnotationDefinition> annotationDefinitionMap = PlannerTestUtil.getComparatorObjectAnnotations();
DataObject dataObject1 = new DataObjectImpl("bar.foo",
"DataObject1");
ObjectProperty dataObject1Property1 = new ObjectPropertyImpl("dataObject1Property1",
"java.lang.Integer",
false);
ObjectProperty dataObject1Property2 = new ObjectPropertyImpl("dataObject1Property2",
"bar.foo.DataObject2",
false);
dataObject1.addProperty(dataObject1Property1);
dataObject1.addProperty(dataObject1Property2);
JavaClassImpl comparatorObject = new JavaClassImpl("",
"DifficultyComparator");
comparatorObject.addInterface(Comparator.class.getName());
comparatorObject.addAnnotation(new AnnotationImpl(annotationDefinitionMap.get(Generated.class.getName())));
Method compareMethod = new MethodImpl("compare",
Arrays.asList(new ParameterImpl(new TypeImpl(dataObject1.getClassName()),
"o1"),
new ParameterImpl(new TypeImpl(dataObject1.getClassName()),
"o2")),
"foo",
new TypeImpl("int"),
Visibility.PUBLIC);
comparatorObject.addMethod(compareMethod);
dataObject1.addNestedClass(comparatorObject);
AnnotationImpl planningEntityAnnotation = new AnnotationImpl(DriverUtils.buildAnnotationDefinition(PlanningEntity.class));
planningEntityAnnotation.setValue("difficultyComparatorClass",
dataObject1.getName() + "." + "DifficultyComparator.class");
dataObject1.addAnnotation(planningEntityAnnotation);
ObjectPropertyPath objectPropertyPath = new ObjectPropertyPathImpl();
objectPropertyPath.appendObjectProperty(dataObject1Property2);
objectPropertyPath.appendObjectProperty(dataObject1Property1);
List<ObjectPropertyPath> objectPropertyPathList = new ArrayList<>(1);
objectPropertyPathList.add(objectPropertyPath);
Annotation comparatorDefinitionAnnotation = ComparatorDefinitionAnnotationValueHandler.createAnnotation(objectPropertyPathList,
annotationDefinitionMap);
comparatorObject.addAnnotation(comparatorDefinitionAnnotation);
DataObject dataObject2 = new DataObjectImpl("bar.foo",
"DataObject2");
ObjectProperty dataObject2Property1 = new ObjectPropertyImpl("dataObject2Property1",
"java.lang.Double",
false);
dataObject2.addProperty(dataObject2Property1);
this.dataObject = dataObject1;
this.comparatorObject = comparatorObject;
}