com.github.javaparser.ast.type.ClassOrInterfaceType Java Examples
The following examples show how to use
com.github.javaparser.ast.type.ClassOrInterfaceType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DecisionConfigGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public List<BodyDeclaration<?>> members() { if (annotator != null) { FieldDeclaration delcFieldDeclaration = annotator.withOptionalInjection(new FieldDeclaration() .addVariable(new VariableDeclarator(genericType(annotator.multiInstanceInjectionType(), DecisionEventListenerConfig.class), VAR_DECISION_EVENT_LISTENER_CONFIG))); members.add(delcFieldDeclaration); FieldDeclaration drelFieldDeclaration = annotator.withOptionalInjection(new FieldDeclaration() .addVariable(new VariableDeclarator(genericType(annotator.multiInstanceInjectionType(), DMNRuntimeEventListener.class), VAR_DMN_RUNTIME_EVENT_LISTENERS))); members.add(drelFieldDeclaration); members.add(generateExtractEventListenerConfigMethod()); members.add(generateMergeEventListenerConfigMethod()); } else { FieldDeclaration defaultDelcFieldDeclaration = new FieldDeclaration() .setModifiers(Modifier.Keyword.PRIVATE) .addVariable(new VariableDeclarator(new ClassOrInterfaceType(null, DecisionEventListenerConfig.class.getCanonicalName()), VAR_DEFAULT_DECISION_EVENT_LISTENER_CONFIG, newObject(DefaultDecisionEventListenerConfig.class))); members.add(defaultDelcFieldDeclaration); } return members; }
Example #2
Source File: ParserTypeUtil.java From JRemapper with MIT License | 6 votes |
/** * @param type * JavaParser type. Must be an object type. * @return Internal descriptor from type, assuming the type is available. */ private static String typeToDesc(Type type) { String key = null; if (type instanceof ClassOrInterfaceType) { try { key = ((ClassOrInterfaceType) type).resolve().getQualifiedName(); } catch(Exception ex) { /* ignored */ } } if (key == null) key = type.asString(); StringBuilder sbDesc = new StringBuilder(); for (int i = 0; i < type.getArrayLevel(); i++) sbDesc.append("["); sbDesc.append("L"); sbDesc.append(key.replace('.', '/')); sbDesc.append(";"); return sbDesc.toString(); }
Example #3
Source File: ImplementsRelationCalculator.java From jql with MIT License | 6 votes |
public void calculate(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, CompilationUnit compilationUnit) { List<ClassOrInterfaceType> implementedInterfaces = classOrInterfaceDeclaration.getImplementedTypes(); for (ClassOrInterfaceType implementedInterface : implementedInterfaces) { String implementedInterfaceName = implementedInterface.getNameAsString(); String implementedInterfacePackageName = implementedInterface .findCompilationUnit() .flatMap(CompilationUnit::getPackageDeclaration) .flatMap(pkg -> Optional.of(pkg.getNameAsString())).orElse("???"); if (typeDao.exist(implementedInterfaceName, implementedInterfacePackageName)) { // JDK interfaces are not indexed int interfaceId = typeDao.getId(implementedInterfaceName, implementedInterfacePackageName); String cuPackageName = compilationUnit.getPackageDeclaration().get().getNameAsString(); int nbClasses = typeDao.count(classOrInterfaceDeclaration.getNameAsString(), cuPackageName); if (nbClasses > 1) { System.err.println("More than one class having the same name '" + classOrInterfaceDeclaration.getName() + "' and package '" + cuPackageName + "'"); } else { int classId = typeDao.getId(classOrInterfaceDeclaration.getNameAsString(), cuPackageName); implementsDao.save(new Implements(classId, interfaceId)); } } } }
Example #4
Source File: TypeParameterMerger.java From dolphin with Apache License 2.0 | 6 votes |
@Override public boolean doIsEquals(TypeParameter first, TypeParameter second) { if(!StringUtils.equals(first.getName(),second.getName())) return false; List<ClassOrInterfaceType> firstTypeBounds = first.getTypeBound(); List<ClassOrInterfaceType> secondTypeBounds = second.getTypeBound(); if(firstTypeBounds == null) return secondTypeBounds == null; if(secondTypeBounds == null) return false; if(firstTypeBounds.size() != secondTypeBounds.size()) return false; AbstractMerger<ClassOrInterfaceType> merger = getMerger(ClassOrInterfaceType.class); for(int i = 0; i < firstTypeBounds.size(); i++){ if(!merger.isEquals(firstTypeBounds.get(i),secondTypeBounds.get(i))){ return false; } } return true; }
Example #5
Source File: ProcessInstanceGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodDeclaration unbind() { String modelName = model.getModelClassSimpleName(); BlockStmt body = new BlockStmt() .addStatement(model.fromMap("variables", "vmap")); return new MethodDeclaration() .setModifiers(Modifier.Keyword.PROTECTED) .setName("unbind") .setType(new VoidType()) .addParameter(modelName, "variables") .addParameter(new ClassOrInterfaceType() .setName("java.util.Map") .setTypeArguments(new ClassOrInterfaceType().setName("String"), new ClassOrInterfaceType().setName("Object")), "vmap") .setBody(body); }
Example #6
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
@Override public void visit(final TypeParameter n, final Void arg) { printJavaComment(n.getComment(), arg); for (AnnotationExpr ann : n.getAnnotations()) { ann.accept(this, arg); printer.print(" "); } n.getName().accept(this, arg); if (!isNullOrEmpty(n.getTypeBound())) { printer.print(" extends "); for (final Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext(); ) { final ClassOrInterfaceType c = i.next(); c.accept(this, arg); if (i.hasNext()) { printer.print(" & "); } } } }
Example #7
Source File: Extends.java From butterfly with MIT License | 6 votes |
@Override protected String getTypeName(CompilationUnit compilationUnit, int index) { ClassOrInterfaceDeclaration type = (ClassOrInterfaceDeclaration) compilationUnit.getType(0); NodeList<ClassOrInterfaceType> extendedTypes = type.getExtendedTypes(); ClassOrInterfaceType extendedType = extendedTypes.get(index); String typeSimpleName = extendedType.getName().getIdentifier(); Optional<ClassOrInterfaceType> scope = extendedType.getScope(); String typeName; if (scope.isPresent()) { String typePackageName = scope.get().toString(); typeName = String.format("%s.%s", typePackageName, typeSimpleName); } else { typeName = typeSimpleName; } return typeName; }
Example #8
Source File: ProcessGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
private MethodDeclaration createInstanceGenericWithBusinessKeyMethod(String processInstanceFQCN) { MethodDeclaration methodDeclaration = new MethodDeclaration(); ReturnStmt returnStmt = new ReturnStmt( new MethodCallExpr(new ThisExpr(), "createInstance") .addArgument(new NameExpr(BUSINESS_KEY)) .addArgument(new CastExpr(new ClassOrInterfaceType(null, modelTypeName), new NameExpr("value")))); methodDeclaration.setName("createInstance") .addModifier(Modifier.Keyword.PUBLIC) .addParameter(String.class.getCanonicalName(), BUSINESS_KEY) .addParameter(Model.class.getCanonicalName(), "value") .setType(processInstanceFQCN) .setBody(new BlockStmt() .addStatement(returnStmt)); return methodDeclaration; }
Example #9
Source File: PrettyPrintVisitor.java From stategen with GNU Affero General Public License v3.0 | 6 votes |
@Override public void visit(final ClassOrInterfaceType n, final Void arg) { printJavaComment(n.getComment(), arg); if (n.getScope().isPresent()) { n.getScope().get().accept(this, arg); printer.print("."); } for (AnnotationExpr ae : n.getAnnotations()) { ae.accept(this, arg); printer.print(" "); } n.getName().accept(this, arg); if (n.isUsingDiamondOperator()) { printer.print("<>"); } else { printTypeArgs(n, arg); } }
Example #10
Source File: ProcessesContainerGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public ProcessesContainerGenerator(String packageName) { super("Processes", "processes", Processes.class); this.packageName = packageName; this.processes = new ArrayList<>(); this.factoryMethods = new ArrayList<>(); this.applicationDeclarations = new NodeList<>(); byProcessIdMethodDeclaration = new MethodDeclaration() .addModifier(Modifier.Keyword.PUBLIC) .setName("processById") .setType(new ClassOrInterfaceType(null, org.kie.kogito.process.Process.class.getCanonicalName()) .setTypeArguments(new WildcardType(new ClassOrInterfaceType(null, Model.class.getCanonicalName())))) .setBody(new BlockStmt()) .addParameter("String", "processId"); processesMethodDeclaration = new MethodDeclaration() .addModifier(Modifier.Keyword.PUBLIC) .setName("processIds") .setType(new ClassOrInterfaceType(null, Collection.class.getCanonicalName()) .setTypeArguments(new ClassOrInterfaceType(null, "String"))) .setBody(new BlockStmt()); applicationDeclarations.add(byProcessIdMethodDeclaration); applicationDeclarations.add(processesMethodDeclaration); }
Example #11
Source File: ForEachNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 6 votes |
@Override public void visitNode(String factoryField, ForEachNode node, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) { body.addStatement(getAssignedFactoryMethod(factoryField, ForEachNodeFactory.class, getNodeId(node), getNodeKey(), new LongLiteralExpr(node.getId()))) .addStatement(getNameMethod(node, "ForEach")); visitMetaData(node.getMetaData(), body, getNodeId(node)); body.addStatement(getFactoryMethod(getNodeId(node), METHOD_COLLECTION_EXPRESSION, new StringLiteralExpr(stripExpression(node.getCollectionExpression())))) .addStatement(getFactoryMethod(getNodeId(node), METHOD_VARIABLE, new StringLiteralExpr(node.getVariableName()), new ObjectCreationExpr(null, new ClassOrInterfaceType(null, ObjectDataType.class.getSimpleName()), NodeList.nodeList( new StringLiteralExpr(node.getVariableType().getStringType()) )))); if (node.getOutputCollectionExpression() != null) { body.addStatement(getFactoryMethod(getNodeId(node), METHOD_OUTPUT_COLLECTION_EXPRESSION, new StringLiteralExpr(stripExpression(node.getOutputCollectionExpression())))) .addStatement(getFactoryMethod(getNodeId(node), METHOD_OUTPUT_VARIABLE, new StringLiteralExpr(node.getOutputVariableName()), new ObjectCreationExpr(null, new ClassOrInterfaceType(null, ObjectDataType.class.getSimpleName()), NodeList.nodeList( new StringLiteralExpr(node.getOutputVariableType().getStringType()) )))); } // visit nodes visitNodes(getNodeId(node), node.getNodes(), body, ((VariableScope) node.getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE)), metadata); body.addStatement(getFactoryMethod(getNodeId(node), METHOD_LINK_INCOMING_CONNECTIONS, new LongLiteralExpr(node.getLinkedIncomingNode(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE).getNodeId()))) .addStatement(getFactoryMethod(getNodeId(node), METHOD_LINK_OUTGOING_CONNECTIONS, new LongLiteralExpr(node.getLinkedOutgoingNode(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE).getNodeId()))) .addStatement(getDoneMethod(getNodeId(node))); }
Example #12
Source File: RuleUnitInstanceGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public ClassOrInterfaceDeclaration classDeclaration() { String canonicalName = ruleUnitDescription.getRuleUnitName(); ClassOrInterfaceDeclaration classDecl = new ClassOrInterfaceDeclaration() .setName(targetTypeName) .addModifier(Modifier.Keyword.PUBLIC); classDecl .addExtendedType( new ClassOrInterfaceType(null, AbstractRuleUnitInstance.class.getCanonicalName()) .setTypeArguments(new ClassOrInterfaceType(null, canonicalName))) .addConstructor(Modifier.Keyword.PUBLIC) .addParameter(RuleUnitGenerator.ruleUnitType(canonicalName), "unit") .addParameter(canonicalName, "value") .addParameter(KieSession.class.getCanonicalName(), "session") .setBody(new BlockStmt().addStatement(new MethodCallExpr( "super", new NameExpr("unit"), new NameExpr("value"), new NameExpr("session") ))); classDecl.addMember(bindMethod()); classDecl.getMembers().sort(new BodyDeclarationComparator()); return classDecl; }
Example #13
Source File: Sources.java From sundrio with Apache License 2.0 | 6 votes |
public TypeRef apply(Type type) { if (type instanceof VoidType) { return new VoidRef(); } else if (type instanceof WildcardType) { return new WildcardRef(); } else if (type instanceof ReferenceType) { ReferenceType referenceType = (ReferenceType) type; int dimensions = referenceType.getArrayCount(); TypeRef typeRef = TYPEREF.apply(referenceType.getType()); if (dimensions == 0) { return typeRef; } else if (typeRef instanceof ClassRef) { return new ClassRefBuilder((ClassRef)typeRef).withDimensions(dimensions).build(); } else if (typeRef instanceof PrimitiveRef) { return new PrimitiveRefBuilder((PrimitiveRef)typeRef).withDimensions(dimensions).build(); } else if (typeRef instanceof TypeParamRef) { return new TypeParamRefBuilder((TypeParamRef)typeRef).withDimensions(dimensions).build(); } } else if (type instanceof PrimitiveType) { PrimitiveType primitiveType = (PrimitiveType) type; return new PrimitiveRefBuilder().withName(primitiveType.getType().name()).build(); } else if (type instanceof ClassOrInterfaceType) { return CLASS_OR_TYPEPARAM_REF.apply((ClassOrInterfaceType) type); } throw new IllegalArgumentException("Can't handle type:[" + type + "]."); }
Example #14
Source File: RuleUnitHandler.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public Expression invoke() { InputStream resourceAsStream = this.getClass().getResourceAsStream("/class-templates/RuleUnitFactoryTemplate.java"); Expression ruleUnitFactory = parse(resourceAsStream).findFirst(Expression.class) .orElseThrow(() -> new IllegalArgumentException("Template does not contain an Expression")); String unitName = ruleUnit.getCanonicalName(); ruleUnitFactory.findAll(ClassOrInterfaceType.class) .stream() .filter(t -> t.getNameAsString().equals("$Type$")) .forEach(t -> t.setName(unitName)); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("bind")) .ifPresent(m -> m.setBody(bind(variableScope, ruleSetNode, ruleUnit))); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("unit")) .ifPresent(m -> m.setBody(unit(unitName))); ruleUnitFactory.findFirst(MethodDeclaration.class, m -> m.getNameAsString().equals("unbind")) .ifPresent(m -> m.setBody(unbind(variableScope, ruleSetNode, ruleUnit))); return ruleUnitFactory; }
Example #15
Source File: TriggerMetaData.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public static LambdaExpr buildLambdaExpr(Node node, ProcessMetaData metadata) { Map<String, Object> nodeMetaData = node.getMetaData(); TriggerMetaData triggerMetaData = new TriggerMetaData( (String) nodeMetaData.get(TRIGGER_REF), (String) nodeMetaData.get(TRIGGER_TYPE), (String) nodeMetaData.get(MESSAGE_TYPE), (String) nodeMetaData.get(MAPPING_VARIABLE), String.valueOf(node.getId())) .validate(); metadata.getTriggers().add(triggerMetaData); // and add trigger action BlockStmt actionBody = new BlockStmt(); CastExpr variable = new CastExpr( new ClassOrInterfaceType(null, triggerMetaData.getDataType()), new MethodCallExpr(new NameExpr(KCONTEXT_VAR), "getVariable") .addArgument(new StringLiteralExpr(triggerMetaData.getModelRef()))); MethodCallExpr producerMethodCall = new MethodCallExpr(new NameExpr("producer_" + node.getId()), "produce").addArgument(new MethodCallExpr(new NameExpr("kcontext"), "getProcessInstance")).addArgument(variable); actionBody.addStatement(producerMethodCall); return new LambdaExpr( new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) -> actionBody ); }
Example #16
Source File: RuleConfigGenerator.java From kogito-runtimes with Apache License 2.0 | 6 votes |
public List<BodyDeclaration<?>> members() { if (annotator != null) { FieldDeclaration relcFieldDeclaration = annotator.withOptionalInjection(new FieldDeclaration().addVariable(new VariableDeclarator(genericType(annotator.multiInstanceInjectionType(), RuleEventListenerConfig.class), VAR_RULE_EVENT_LISTENER_CONFIGS))); members.add(relcFieldDeclaration); FieldDeclaration aelFieldDeclaration = annotator.withOptionalInjection(new FieldDeclaration().addVariable(new VariableDeclarator(genericType(annotator.multiInstanceInjectionType(), AgendaEventListener.class), VAR_AGENDA_EVENT_LISTENERS))); members.add(aelFieldDeclaration); FieldDeclaration rrelFieldDeclaration = annotator.withOptionalInjection(new FieldDeclaration().addVariable(new VariableDeclarator(genericType(annotator.multiInstanceInjectionType(), RuleRuntimeEventListener.class), VAR_RULE_RUNTIME_EVENT_LISTENERS))); members.add(rrelFieldDeclaration); members.add(generateExtractEventListenerConfigMethod()); members.add(generateMergeEventListenerConfigMethod()); } else { FieldDeclaration defaultRelcFieldDeclaration = new FieldDeclaration() .setModifiers(Modifier.Keyword.PRIVATE) .addVariable(new VariableDeclarator(new ClassOrInterfaceType(null, RuleEventListenerConfig.class.getCanonicalName()), VAR_DEFAULT_RULE_EVENT_LISTENER_CONFIG, newObject(DefaultRuleEventListenerConfig.class))); members.add(defaultRelcFieldDeclaration); } return members; }
Example #17
Source File: ConstructorInitialization.java From TestSmellDetector with GNU General Public License v3.0 | 5 votes |
@Override public void visit(ClassOrInterfaceDeclaration n, Void arg) { for(int i=0;i<n.getExtendedTypes().size();i++){ ClassOrInterfaceType node = n.getExtendedTypes().get(i); constructorAllowed = node.getNameAsString().equals("ActivityInstrumentationTestCase2"); } super.visit(n, arg); }
Example #18
Source File: JavaInterfaceBuilderImpl.java From chrome-devtools-java-client with Apache License 2.0 | 5 votes |
@Override public void addParametrizedMethodAnnotation( String methodName, String annotationName, String parameter) { List<MethodDeclaration> methods = declaration.getMethodsByName(methodName); for (MethodDeclaration methodDeclaration : methods) { Optional<AnnotationExpr> annotation = methodDeclaration.getAnnotationByName(annotationName); if (!annotation.isPresent()) { if (isClassList(parameter)) { final List<String> classList = getClassList(parameter); if (classList.size() == 1) { methodDeclaration.addSingleMemberAnnotation( annotationName, new ClassExpr(new ClassOrInterfaceType(getClassName(classList.get(0))))); } else { final List<Expression> nodes = classList .stream() .map(clazz -> new ClassExpr(new ClassOrInterfaceType(getClassName(clazz)))) .collect(Collectors.toList()); methodDeclaration.addSingleMemberAnnotation( annotationName, new ArrayInitializerExpr(new NodeList<>(nodes))); } } else { methodDeclaration.addSingleMemberAnnotation( annotationName, new StringLiteralExpr(parameter)); } } } importAnnotation(annotationName); }
Example #19
Source File: ClassOrInterfaceTypeMerger.java From dolphin with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public boolean doIsEquals(ClassOrInterfaceType first, ClassOrInterfaceType second) { if(!StringUtils.equals(first.getName(),second.getName())) return false; // check type args in order List<Type> firstTypeArgs = first.getTypeArgs(); List<Type> secondTypeArgs = second.getTypeArgs(); if(firstTypeArgs == secondTypeArgs) return true; if(firstTypeArgs == null || secondTypeArgs == null) return false; for(int i = 0; i < firstTypeArgs.size(); i++){ Type ft = firstTypeArgs.get(i); Type st = secondTypeArgs.get(i); if(ft.getClass().equals(st.getClass())) { AbstractMerger merger = getMerger(ft.getClass()); if(!merger.isEquals(ft,st)) return false; }else { return false; } } // check scope recursively if(isAllNotNull(first.getScope(),second.getScope())){ if(!isEquals(first.getScope(),second.getScope())) return false; }else if(!isAllNull(first.getScope(),second.getScope())){ return false; } return true; }
Example #20
Source File: ModelMetaData.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public AssignExpr newInstance(String assignVarName) { ClassOrInterfaceType type = new ClassOrInterfaceType(null, modelClassName); return new AssignExpr( new VariableDeclarationExpr(type, assignVarName), new ObjectCreationExpr().setType(type), AssignExpr.Operator.ASSIGN); }
Example #21
Source File: Sources.java From sundrio with Apache License 2.0 | 5 votes |
public TypeParamDef apply(TypeParameter typeParameter) { List<ClassRef> bounds = new ArrayList<ClassRef>(); for (ClassOrInterfaceType classOrInterfaceType : typeParameter.getTypeBound()) { bounds.add((ClassRef) CLASS_OR_TYPEPARAM_REF.apply(classOrInterfaceType)); } return new TypeParamDefBuilder() .withName(typeParameter.getName()) .withBounds(bounds) .build(); }
Example #22
Source File: OpenApiObjectGenerator.java From flow with Apache License 2.0 | 5 votes |
private List<Schema> parseNonEndpointClassAsSchema( String fullQualifiedName) { TypeDeclaration<?> typeDeclaration = nonEndpointMap.get(fullQualifiedName); if (typeDeclaration == null || typeDeclaration.isEnumDeclaration()) { return Collections.emptyList(); } List<Schema> result = new ArrayList<>(); Schema schema = createSingleSchema(fullQualifiedName, typeDeclaration); generatedSchema.add(fullQualifiedName); NodeList<ClassOrInterfaceType> extendedTypes = null; if (typeDeclaration.isClassOrInterfaceDeclaration()) { extendedTypes = typeDeclaration.asClassOrInterfaceDeclaration() .getExtendedTypes(); } if (extendedTypes == null || extendedTypes.isEmpty()) { result.add(schema); result.addAll(generatedRelatedSchemas(schema)); } else { ComposedSchema parentSchema = new ComposedSchema(); parentSchema.setName(fullQualifiedName); result.add(parentSchema); extendedTypes.forEach(parentType -> { ResolvedReferenceType resolvedParentType = parentType.resolve(); String parentQualifiedName = resolvedParentType .getQualifiedName(); String parentRef = schemaResolver .getFullQualifiedNameRef(parentQualifiedName); parentSchema.addAllOfItem(new ObjectSchema().$ref(parentRef)); schemaResolver.addFoundTypes(parentQualifiedName, resolvedParentType); }); // The inserting order matters for `allof` property. parentSchema.addAllOfItem(schema); result.addAll(generatedRelatedSchemas(parentSchema)); } return result; }
Example #23
Source File: CompositeContextNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
protected void visitVariableScope(String contextNode, VariableScope variableScope, BlockStmt body, Set<String> visitedVariables) { if (variableScope != null && !variableScope.getVariables().isEmpty()) { for (Variable variable : variableScope.getVariables()) { if (!visitedVariables.add(variable.getName())) { continue; } String tags = (String) variable.getMetaData(Variable.VARIABLE_TAGS); ClassOrInterfaceType variableType = new ClassOrInterfaceType(null, ObjectDataType.class.getSimpleName()); ObjectCreationExpr variableValue = new ObjectCreationExpr(null, variableType, new NodeList<>(new StringLiteralExpr(variable.getType().getStringType()))); body.addStatement(getFactoryMethod(contextNode, METHOD_VARIABLE, new StringLiteralExpr(variable.getName()), variableValue, new StringLiteralExpr(Variable.VARIABLE_TAGS), (tags != null ? new StringLiteralExpr(tags) : new NullLiteralExpr()))); } } }
Example #24
Source File: JavaClassSyncHandler.java From jeddict with Apache License 2.0 | 5 votes |
private void syncExtendedTypes(List<ClassOrInterfaceType> extendedTypes, Map<String, ImportDeclaration> imports) { if (extendedTypes.size() != 1) { return; // single extends is valid for entity } ClassOrInterfaceType extendedType = extendedTypes.get(0); String value = extendedType.toString(); if (javaClass.getSuperclassRef() == null && javaClass.getSuperclass() == null) { javaClass.setRuntimeSuperclassRef(new ReferenceClass(value)); syncImportSnippet(value, imports);; } }
Example #25
Source File: AbstractNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
protected Statement makeAssignmentFromModel(Variable v, String name) { ClassOrInterfaceType type = parseClassOrInterfaceType(v.getType().getStringType()); // `type` `name` = (`type`) `model.get<Name> AssignExpr assignExpr = new AssignExpr( new VariableDeclarationExpr(type, name), new CastExpr( type, new MethodCallExpr( new NameExpr("model"), "get" + StringUtils.capitalize(name))), AssignExpr.Operator.ASSIGN); return new ExpressionStmt(assignExpr); }
Example #26
Source File: TypeParameterToJavaType.java From sundrio with Apache License 2.0 | 5 votes |
public TypeRef apply(TypeParameter item) { List<TypeRef> interfaces = new ArrayList<TypeRef>(); for (ClassOrInterfaceType classOrInterfaceType : item.getTypeBound()) { } return null; }
Example #27
Source File: AbstractNodeVisitor.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static Statement makeAssignment(String targetLocalVariable, Variable processVariable) { ClassOrInterfaceType type = parseClassOrInterfaceType(processVariable.getType().getStringType()); // `type` `name` = (`type`) `kcontext.getVariable AssignExpr assignExpr = new AssignExpr( new VariableDeclarationExpr(type, targetLocalVariable), new CastExpr( type, new MethodCallExpr( new NameExpr(KCONTEXT_VAR), "getVariable") .addArgument(new StringLiteralExpr(targetLocalVariable))), AssignExpr.Operator.ASSIGN); return new ExpressionStmt(assignExpr); }
Example #28
Source File: ConfigGenerator.java From kogito-runtimes with Apache License 2.0 | 5 votes |
public static MethodCallExpr callMerge(String configsName, Class<?> configToListenersScope, String configToListenersIdentifier, String listenersName) { return new MethodCallExpr(null, "merge", NodeList.nodeList( new NameExpr(configsName), new MethodReferenceExpr( new TypeExpr(new ClassOrInterfaceType(null, configToListenersScope.getCanonicalName())), null, configToListenersIdentifier ), new NameExpr(listenersName) )); }
Example #29
Source File: ClassOrInterfaceTypeToTypeDef.java From sundrio with Apache License 2.0 | 5 votes |
public TypeDef apply(ClassOrInterfaceType item) { List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(); for (Type type : item.getTypeArgs()) { new TypeParamDefBuilder() .build(); } return new TypeDefBuilder() .withName(item.getName()) .withParameters(parameters) .build(); }
Example #30
Source File: ImmutableBeanGenerator.java From state-machine with Apache License 2.0 | 5 votes |
private static void writeClassDeclaration(PrintStream s, ClassOrInterfaceDeclaration c) { s.format("\npublic%s class %s", c.isFinal() ? " final" : "", c.getName()); if (c.getImplementedTypes() != null && !c.getImplementedTypes().isEmpty()) { s.format(" implements"); for (ClassOrInterfaceType iface : c.getImplementedTypes()) { s.append(" " + iface); } } s.append(" {\n"); Preconditions.checkArgument(c.getExtendedTypes().size() == 0); }