Search in sources :

Example 6 with Visibility

use of org.kie.workbench.common.services.datamodeller.core.Visibility in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriver method addMethod.

private void addMethod(org.kie.workbench.common.services.datamodeller.core.JavaClass javaClass, Method method, ClassTypeResolver classTypeResolver) throws ClassNotFoundException, ModelDriverException {
    List<Parameter> parameters = method.getParameters();
    List<org.kie.workbench.common.services.datamodeller.core.Parameter> modelParameters = new ArrayList<>();
    if (parameters != null) {
        for (Parameter parameter : parameters) {
            modelParameters.add(new org.kie.workbench.common.services.datamodeller.core.impl.ParameterImpl(new org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl(resolveTypeName(classTypeResolver, parameter.getType().getName()), resolveTypeArguments(parameter.getType().getTypeArguments())), parameter.getName()));
        }
    }
    org.kie.workbench.common.services.datamodeller.core.Type returnType = null;
    if (method.getReturnType() != null) {
        returnType = new org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl(resolveTypeName(classTypeResolver, method.getReturnType().getName()), resolveTypeArguments(method.getReturnType().getTypeArguments()));
    }
    Visibility visibility = Visibility.PACKAGE_PRIVATE;
    if (method.getVisibility() != null) {
        visibility = DriverUtils.buildVisibility(method.getVisibility());
    }
    MethodImpl dataObjectMethod = new MethodImpl(method.getName(), modelParameters, method.getBody(), returnType, visibility);
    List<AnnotationSource<JavaClassSource>> annotations = method.getAnnotations();
    if (annotations != null) {
        for (AnnotationSource annotation : annotations) {
            dataObjectMethod.addAnnotation(createAnnotation(annotation, classTypeResolver));
        }
    }
    javaClass.addMethod(dataObjectMethod);
}
Also used : ArrayList(java.util.ArrayList) MethodImpl(org.kie.workbench.common.services.datamodeller.core.impl.MethodImpl) AnnotationSource(org.jboss.forge.roaster.model.source.AnnotationSource) Parameter(org.jboss.forge.roaster.model.Parameter) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility)

Example 7 with Visibility

use of org.kie.workbench.common.services.datamodeller.core.Visibility in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriver method loadFromJavaEnum.

private void loadFromJavaEnum(JavaEnumSource javaEnumSource, Path file, DataModel dataModel, ModelDriverResult result) {
    String className = javaEnumSource.getName();
    String packageName = javaEnumSource.getPackage();
    Visibility visibility = DriverUtils.buildVisibility(javaEnumSource.getVisibility());
    JavaEnumImpl javaEnum = new JavaEnumImpl(packageName, className, visibility);
    dataModel.addJavaEnum(javaEnum);
    result.setClassPath(javaEnum.getClassName(), Paths.convert(file));
}
Also used : JavaEnumImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl) Visibility(org.kie.workbench.common.services.datamodeller.core.Visibility)

Aggregations

Visibility (org.kie.workbench.common.services.datamodeller.core.Visibility)7 ArrayList (java.util.ArrayList)3 AnnotationSource (org.jboss.forge.roaster.model.source.AnnotationSource)3 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)3 ObjectProperty (org.kie.workbench.common.services.datamodeller.core.ObjectProperty)3 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)2 JavaEnumImpl (org.kie.workbench.common.services.datamodeller.core.impl.JavaEnumImpl)2 ObjectPropertyImpl (org.kie.workbench.common.services.datamodeller.core.impl.ObjectPropertyImpl)2 ModelDriverException (org.kie.workbench.common.services.datamodeller.driver.ModelDriverException)2 List (java.util.List)1 Set (java.util.Set)1 JavaType (org.jboss.forge.roaster.model.JavaType)1 Method (org.jboss.forge.roaster.model.Method)1 Parameter (org.jboss.forge.roaster.model.Parameter)1 Type (org.jboss.forge.roaster.model.Type)1 FieldSource (org.jboss.forge.roaster.model.source.FieldSource)1 Import (org.jboss.forge.roaster.model.source.Import)1 JavaClassSource (org.jboss.forge.roaster.model.source.JavaClassSource)1 JavaSource (org.jboss.forge.roaster.model.source.JavaSource)1 MethodSource (org.jboss.forge.roaster.model.source.MethodSource)1