public OJIfStatement(String condition) { this.setThenPart(new OJBlock()); this.setCondition(condition); }
public OJIfStatement(String condition, String thenPart) { super(); this.setThenPart(new OJBlock()); this.setCondition(condition); this.addToThenPart(thenPart); }
public OJIfStatement(String condition, String thenPart, String elsePart) { super(); this.setThenPart(new OJBlock()); this.setCondition(condition); this.addToThenPart(thenPart); this.addToElsePart(elsePart); }
public void renameAll(Set<OJPathName> renamePathNames, String suffix) { setCondition(replaceAll(getCondition(), renamePathNames, suffix)); if (getThenPart() != null) { getThenPart().renameAll(renamePathNames, suffix); } if (getElsePart() != null) { getElsePart().renameAll(renamePathNames, suffix); } }
/** Copies all attributes and associations of this instance into 'copy'. True parts, i.e. associations marked 'aggregate' or 'composite', and attributes, are copied as well. References to other objects, i.e. associations not marked 'aggregate' or 'composite', will not be copied. The 'copy' will refer to the same objects as the original (this) instance. * * @param copy */ public void copyInfoInto(OJIfStatement copy) { super.copyInfoInto(copy); copy.setCondition(getCondition()); if ( getThenPart() != null ) { copy.setThenPart(getThenPart()); } if ( getElsePart() != null ) { copy.setElsePart(getElsePart()); } }
public void copyDeepInfoInto(OJIfStatement copy) { super.copyDeepInfoInto(copy); copy.setCondition(getCondition()); if (getThenPart() != null) { copy.setThenPart(getThenPart().getDeepCopy()); } if (getElsePart() != null) { copy.setElsePart(getElsePart().getDeepCopy()); } }
ojIfStatement.setCondition("result != null"); ojIfStatement.addToThenPart("return result"); finder.getBody().addToStatements(ojIfStatement);
ifHasNotNull.setCondition(qualifier.fieldname() + " != null"); ifHasNotNull.addToThenPart("graphTraversal.has(" + "\"" + qualifier.getQualifierCorrespondingQualifierStereotypedProperty().getPersistentName() +
OJAnnotatedOperation setter = owner.findOperation(pWrap.setter(), pWrap.javaBaseTypePath()); OJIfStatement ifIndexNotNull = new OJIfStatement(); ifIndexNotNull.setCondition( pWrap.fieldname() + " != null && !" + pWrap.fieldname() + ".equals("+pWrap.getter()+"()) && " + UmlgGenerationUtil.UMLGAccess + "." + UmlgGenerationUtil.getFromUniqueIndex + "(" +
private void addConstraints(OJAnnotatedClass annotatedClass, Class clazz) { List<Constraint> constraints = ModelLoader.INSTANCE.getConstraints(clazz); for (Constraint constraint : constraints) { ConstraintWrapper constraintWrapper = new ConstraintWrapper(constraint); OJAnnotatedOperation checkClassConstraint = new OJAnnotatedOperation(UmlgClassOperations.checkClassConstraintName(constraint)); checkClassConstraint.setReturnType(new OJPathName("java.util.List").addToGenerics(UmlgGenerationUtil.UmlgConstraintViolation)); OJField result = new OJField("result", new OJPathName("java.util.List").addToGenerics(UmlgGenerationUtil.UmlgConstraintViolation)); result.setInitExp("new ArrayList<" + UmlgGenerationUtil.UmlgConstraintViolation.getLast() + ">()"); OJIfStatement ifConstraintFails = new OJIfStatement(); String ocl = constraintWrapper.getConstraintOclAsString(); checkClassConstraint.setComment(String.format("Implements the ocl statement for constraint '%s'\n<pre>\n%s\n</pre>", constraintWrapper.getName(), ocl)); OCLExpression<Classifier> oclExp = UmlgOcl2Parser.INSTANCE.parseOcl(ocl); ifConstraintFails.setCondition("(" + UmlgOcl2Java.oclToJava(clazz, annotatedClass, oclExp) + ") == false"); ifConstraintFails.addToThenPart("result.add(new " + UmlgGenerationUtil.UmlgConstraintViolation.getLast() + "(\"" + constraintWrapper.getName() + "\", \"" + clazz.getQualifiedName() + "\", \"ocl\\n" + ocl.replace("\n", "\\n") + "\\nfails!\"))"); checkClassConstraint.getBody().addToStatements(ifConstraintFails); checkClassConstraint.getBody().addToLocals(result); checkClassConstraint.getBody().addToStatements("return result"); annotatedClass.addToOperations(checkClassConstraint); } }
String condition = "parentResource.getClass() == " + UmlgClassOperations.getPathName(concreteClassifierFrom).getLast() + ".class"; if (countFrom == 1) { ifStatementFrom.setCondition(condition); ifStatementFrom.setThenPart(conditionBlockFrom); } else if (countFrom == concreteImplementationsFrom.size()) {
public static void buildDeleteNotification(OJAnnotatedClass owner, OJAnnotatedOperation delete, PropertyWrapper propertyWrapper) { OJIfStatement ifChanged = new OJIfStatement(); ifChanged.setCondition("true"); PropertyWrapper otherEnd = PropertyWrapper.from(propertyWrapper.getOtherEnd()); if (otherEnd.isMany()) { OJForStatement forStatement = new OJForStatement(otherEnd.getName(), otherEnd.javaBaseTypePath(), "this." + otherEnd.getter() + "()"); forStatement.getBody().addToStatements(constructNotifierForOtherEndMany(propertyWrapper, otherEnd)); delete.getBody().addToStatements(0, forStatement); } else { ifChanged.addToThenPart( constructNotifier(propertyWrapper) ); delete.getBody().addToStatements(0, ifChanged); } owner.addToImports(UmlgClassOperations.getPathName(propertyWrapper.getOwningType()).append(UmlgClassOperations.propertyEnumName(propertyWrapper.getOwningType()))); owner.addToImports(UmlgGenerationUtil.UmlgNotificationManager); owner.addToImports(UmlgGenerationUtil.ChangeHolder); owner.addToImports(UmlgGenerationUtil.ChangeHolder); owner.addToImports("java.util.Optional"); }
for (Property otherEndToComposite : otherEndsToComposite) { if (count++ == 1) { ifCompositeParentNotNull.setCondition(new PropertyWrapper(otherEndToComposite).getter() + "() != null"); ifCompositeParentNotNull.addToThenPart("result = " + new PropertyWrapper(otherEndToComposite).getter() + "()"); } else {
String condition = "resource.getClass() == " + UmlgClassOperations.getPathName(concreteClassifierFrom).getLast() + ".class"; if (countFrom == 1) { ifStatementFrom.setCondition(condition); ifStatementFrom.setThenPart(conditionBlockFrom); } else if (countFrom == concreteImplementationsFrom.size()) {
String condition = "parentResource.getClass() == " + UmlgClassOperations.getPathName(concreteClassifierFrom).getLast() + ".class"; if (countFrom == 1) { ifStatementFrom.setCondition(condition); ifStatementFrom.setThenPart(conditionBlockFrom); } else if (countFrom == concreteImplementationsFrom.size()) {
ojIfStatement.setCondition("runtimeProperty != null"); OJSwitchStatement ojSwitchStatement = new OJSwitchStatement(); ojSwitchStatement.setCondition("runtimeProperty");
ojWhileStatement.getBody().addToStatements("List<UmlgConstraintViolation> violation" + c.getName() + " = " + UmlgClassOperations.checkClassConstraintName(c) + "()"); OJIfStatement ifConstraintFails = new OJIfStatement(); ifConstraintFails.setCondition("!violation" + c.getName() + ".isEmpty()"); ifConstraintFails.getThenPart().addToStatements("iter.remove()"); ojWhileStatement.getBody().addToStatements(ifConstraintFails);
ojIfStatement.setCondition("runtimeProperty != null"); OJSwitchStatement ojSwitchStatement = new OJSwitchStatement(); ojSwitchStatement.setCondition("runtimeProperty");
ojIfStatement.setCondition("runtimeProperty != null"); OJSwitchStatement ojSwitchStatement = new OJSwitchStatement(); ojSwitchStatement.setCondition("runtimeProperty");
if (first) { first = false; ifClassInstanceOf.setCondition("baseClass.equals(" + UmlgClassOperations.getPathName(concreteImplementation).getLast() + ".class)"); ojIfBlock = ifClassInstanceOf.getThenPart(); } else {