[486722] Eliminate unnecessary non-null enforcement
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index 2efaf1b..23abedf 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -1702,14 +1702,20 @@
js.append(" = ");
Map<Property, String> oppositeProperties = getGlobalContext().getOppositeProperties();
if (oppositeProperties != null) {
+ boolean isRequired = cgPropertyCallExp.isRequired();
String cacheName = oppositeProperties.get(asProperty);
if (cacheName != null) {
- js.appendClassReference(ClassUtil.class);
- js.append(".nonNullState (");
+ if (isRequired) {
+ js.appendClassReference(ClassUtil.class);
+ js.append(".nonNullState (");
+ }
js.append(cacheName);
js.append(".get(");
js.appendValueName(source);
- js.append("))");
+ js.append(")");
+ if (isRequired) {
+ js.append(")");
+ }
}
js.append(";\n");
}