Code Review
/
mdsal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Annotate non-null build() return
[mdsal.git]
/
binding
/
mdsal-binding-java-api-generator
/
src
/
main
/
java
/
org
/
opendaylight
/
mdsal
/
binding
/
java
/
api
/
generator
/
BuilderTemplate.xtend
diff --git
a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend
b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend
index 549574bf12d6902c2b22523cb7f9d67b70d46f19..fe0c37e1c5d54442fc4cf03030aa73e021501be5 100644
(file)
--- a/
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend
+++ b/
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend
@@
-70,11
+70,26
@@
class BuilderTemplate extends AbstractBuilderTemplate {
«constantsDeclarations()»
«IF augmentType !== null»
«constantsDeclarations()»
«IF augmentType !== null»
- «generateAugmentField()»
+ «val augmentTypeRef = augmentType.importedName»
+ «val mapTypeRef = JU_MAP.importedName»
+ «mapTypeRef»<«CLASS.importedName»<? extends «augmentTypeRef»>, «augmentTypeRef»> «AUGMENTATION_FIELD» = «mapTypeRef».of();
«ENDIF»
«ENDIF»
+ /**
+ * Construct an empty builder.
+ */
+ public «type.name»() {
+ // No-op
+ }
+
«generateConstructorsFromIfcs()»
«generateConstructorsFromIfcs()»
+ «val targetTypeName = targetType.importedName»
+ /**
+ * Construct a builder initialized with state from specified {@link «targetTypeName»}.
+ *
+ * @param base «targetTypeName» from which the builder should be initialized
+ */
public «generateCopyConstructor(targetType, type.enclosedTypes.get(0))»
«generateMethodFieldsFrom()»
public «generateCopyConstructor(targetType, type.enclosedTypes.get(0))»
«generateMethodFieldsFrom()»
@@
-88,11
+103,11
@@
class BuilderTemplate extends AbstractBuilderTemplate {
«generateSetters»
/**
«generateSetters»
/**
- * A new {@link «targetType
.n
ame»} instance.
+ * A new {@link «targetType
N
ame»} instance.
*
*
- * @return A new {@link «targetType
.n
ame»} instance.
+ * @return A new {@link «targetType
N
ame»} instance.
*/
*/
- public «targetType.
name
» build() {
+ public «targetType.
importedNonNull
» build() {
return new «type.enclosedTypes.get(0).importedName»(this);
}
return new «type.enclosedTypes.get(0).importedName»(this);
}
@@
-112,9
+127,6
@@
class BuilderTemplate extends AbstractBuilderTemplate {
* Generate default constructor and constructor for every implemented interface from uses statements.
*/
def private generateConstructorsFromIfcs() '''
* Generate default constructor and constructor for every implemented interface from uses statements.
*/
def private generateConstructorsFromIfcs() '''
- public «type.name»() {
- }
-
«IF (!(targetType instanceof GeneratedTransferObject))»
«FOR impl : targetType.implements SEPARATOR "\n"»
«generateConstructorFromIfc(impl)»
«IF (!(targetType instanceof GeneratedTransferObject))»
«FOR impl : targetType.implements SEPARATOR "\n"»
«generateConstructorFromIfc(impl)»
@@
-128,9
+140,16
@@
class BuilderTemplate extends AbstractBuilderTemplate {
def private Object generateConstructorFromIfc(Type impl) '''
«IF (impl instanceof GeneratedType)»
«IF impl.hasNonDefaultMethods»
def private Object generateConstructorFromIfc(Type impl) '''
«IF (impl instanceof GeneratedType)»
«IF impl.hasNonDefaultMethods»
- public «type.name»(«impl.importedName» arg) {
+ «val typeName = impl.importedName»
+ /**
+ * Construct a new builder initialized from specified {@link «typeName»}.
+ *
+ * @param arg «typeName» from which the builder should be initialized
+ */
+ public «type.name»(«typeName» arg) {
«printConstructorPropertySetter(impl)»
}
«printConstructorPropertySetter(impl)»
}
+
«ENDIF»
«FOR implTypeImplement : impl.implements»
«generateConstructorFromIfc(implTypeImplement)»
«ENDIF»
«FOR implTypeImplement : impl.implements»
«generateConstructorFromIfc(implTypeImplement)»
@@
-410,7
+429,6
@@
class BuilderTemplate extends AbstractBuilderTemplate {
«IF augmentType !== null»
«val augmentTypeRef = augmentType.importedName»
«IF augmentType !== null»
«val augmentTypeRef = augmentType.importedName»
- «val jlClassRef = CLASS.importedName»
«val hashMapRef = JU_HASHMAP.importedName»
/**
* Add an augmentation to this builder's product.
«val hashMapRef = JU_HASHMAP.importedName»
/**
* Add an augmentation to this builder's product.
@@
-420,12
+438,11
@@
class BuilderTemplate extends AbstractBuilderTemplate {
* @throws NullPointerException if {@code augmentation} is null
*/
public «type.name» addAugmentation(«augmentTypeRef» augmentation) {
* @throws NullPointerException if {@code augmentation} is null
*/
public «type.name» addAugmentation(«augmentTypeRef» augmentation) {
- «jlClassRef»<? extends «augmentTypeRef»> augmentationType = augmentation.«BINDING_CONTRACT_IMPLEMENTED_INTERFACE_NAME»();
if (!(this.«AUGMENTATION_FIELD» instanceof «hashMapRef»)) {
this.«AUGMENTATION_FIELD» = new «hashMapRef»<>();
}
if (!(this.«AUGMENTATION_FIELD» instanceof «hashMapRef»)) {
this.«AUGMENTATION_FIELD» = new «hashMapRef»<>();
}
- this.«AUGMENTATION_FIELD».put(augmentation
Type
, augmentation);
+ this.«AUGMENTATION_FIELD».put(augmentation
.«BINDING_CONTRACT_IMPLEMENTED_INTERFACE_NAME»()
, augmentation);
return this;
}
return this;
}
@@
-436,7
+453,7
@@
class BuilderTemplate extends AbstractBuilderTemplate {
* @param augmentationType augmentation type to be removed
* @return this builder
*/
* @param augmentationType augmentation type to be removed
* @return this builder
*/
- public «type.name» removeAugmentation(«
jlClassRef
»<? extends «augmentTypeRef»> augmentationType) {
+ public «type.name» removeAugmentation(«
CLASS.importedName
»<? extends «augmentTypeRef»> augmentationType) {
if (this.«AUGMENTATION_FIELD» instanceof «hashMapRef») {
this.«AUGMENTATION_FIELD».remove(augmentationType);
}
if (this.«AUGMENTATION_FIELD» instanceof «hashMapRef») {
this.«AUGMENTATION_FIELD».remove(augmentationType);
}