use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class KiePMMLModelFactoryUtils method addGetCreatedKiePMMLOutputFieldsMethod.
public static void addGetCreatedKiePMMLOutputFieldsMethod(final ClassOrInterfaceDeclaration modelTemplate, final List<org.dmg.pmml.OutputField> outputFields) {
final MethodDeclaration methodDeclaration = modelTemplate.addMethod(GET_CREATED_KIEPMMLOUTPUTFIELDS, Modifier.Keyword.PRIVATE);
final ClassOrInterfaceType returnedType = getTypedClassOrInterfaceTypeByTypeNames(List.class.getSimpleName(), Collections.singletonList(KiePMMLOutputField.class.getSimpleName()));
methodDeclaration.setType(returnedType);
commonPopulateGetCreatedKiePMMLOutputFieldsMethod(methodDeclaration, outputFields);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class KiePMMLModelFactoryUtils method addGetCreatedKiePMMLMiningFieldsMethod.
/**
* Add the <code>getCreatedKiePMMLMiningFields</code> method to the given <code>ClassOrInterfaceDeclaration</code>
* @param modelTemplate
* @param miningFields
* @param fields
*/
public static void addGetCreatedKiePMMLMiningFieldsMethod(final ClassOrInterfaceDeclaration modelTemplate, final List<org.dmg.pmml.MiningField> miningFields, final List<org.dmg.pmml.Field<?>> fields) {
final MethodDeclaration methodDeclaration = modelTemplate.addMethod(GET_CREATED_KIEPMMLMININGFIELDS, Modifier.Keyword.PRIVATE);
final ClassOrInterfaceType returnedType = getTypedClassOrInterfaceTypeByTypeNames(List.class.getSimpleName(), Collections.singletonList(KiePMMLMiningField.class.getSimpleName()));
methodDeclaration.setType(returnedType);
commonPopulateGetCreatedKiePMMLMiningFieldsMethod(methodDeclaration, miningFields, fields);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class KiePMMLClusteringModelFactory method comparisonMeasureCreationExprFrom.
private static ObjectCreationExpr comparisonMeasureCreationExprFrom(ComparisonMeasure comparisonMeasure) {
NodeList<Expression> arguments = new NodeList<>();
arguments.add(literalExprFrom(comparisonMeasureKindFrom(comparisonMeasure.getKind())));
arguments.add(literalExprFrom(aggregateFunctionFrom(comparisonMeasure.getMeasure())));
arguments.add(literalExprFrom(compareFunctionFrom(comparisonMeasure.getCompareFunction())));
return new ObjectCreationExpr(null, new ClassOrInterfaceType(null, KiePMMLComparisonMeasure.class.getCanonicalName()), arguments);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project drools by kiegroup.
the class KiePMMLNodeFactory method getKiePMMLScoreDistribution.
static ObjectCreationExpr getKiePMMLScoreDistribution(final String variableName, final ScoreDistribution scoreDistribution) {
final NodeList<Expression> scoreDistributionsArguments = new NodeList<>();
scoreDistributionsArguments.add(getExpressionForObject(variableName));
scoreDistributionsArguments.add(new NullLiteralExpr());
scoreDistributionsArguments.add(getExpressionForObject(scoreDistribution.getValue().toString()));
scoreDistributionsArguments.add(getExpressionForObject(scoreDistribution.getRecordCount().intValue()));
Expression confidenceExpression = scoreDistribution.getConfidence() != null ? getExpressionForObject(scoreDistribution.getConfidence().doubleValue()) : new NullLiteralExpr();
scoreDistributionsArguments.add(confidenceExpression);
Expression probabilityExpression = scoreDistribution.getProbability() != null ? getExpressionForObject(scoreDistribution.getProbability().doubleValue()) : new NullLiteralExpr();
scoreDistributionsArguments.add(probabilityExpression);
return new ObjectCreationExpr(null, new ClassOrInterfaceType(null, KiePMMLScoreDistribution.class.getCanonicalName()), scoreDistributionsArguments);
}
use of com.github.javaparser.ast.type.ClassOrInterfaceType in project checker-framework by typetools.
the class AnnotationFileParser method sameType.
/**
* Returns true if the two types are the same.
*
* @param javacType type in javac form
* @param javaParserType type in JavaParser form
* @return true if the two types are the same
*/
private boolean sameType(TypeMirror javacType, Type javaParserType) {
switch(javacType.getKind()) {
case BOOLEAN:
return javaParserType.equals(PrimitiveType.booleanType());
case BYTE:
return javaParserType.equals(PrimitiveType.byteType());
case CHAR:
return javaParserType.equals(PrimitiveType.charType());
case DOUBLE:
return javaParserType.equals(PrimitiveType.doubleType());
case FLOAT:
return javaParserType.equals(PrimitiveType.floatType());
case INT:
return javaParserType.equals(PrimitiveType.intType());
case LONG:
return javaParserType.equals(PrimitiveType.longType());
case SHORT:
return javaParserType.equals(PrimitiveType.shortType());
case DECLARED:
case TYPEVAR:
if (!(javaParserType instanceof ClassOrInterfaceType)) {
return false;
}
com.sun.tools.javac.code.Type javacTypeInternal = (com.sun.tools.javac.code.Type) javacType;
ClassOrInterfaceType javaParserClassType = (ClassOrInterfaceType) javaParserType;
// Use asString() because toString() includes annotations.
String javaParserString = javaParserClassType.asString();
Element javacElement = javacTypeInternal.asElement();
// Check both fully-qualified name and simple name.
return javacElement.toString().equals(javaParserString) || javacElement.getSimpleName().contentEquals(javaParserString);
case ARRAY:
return javaParserType.isArrayType() && sameType(((ArrayType) javacType).getComponentType(), javaParserType.asArrayType().getComponentType());
default:
throw new BugInCF("Unhandled type %s of kind %s", javacType, javacType.getKind());
}
}
Aggregations