use of org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder in project mdsal by opendaylight.
the class AbstractGeneratedTOBuilder method addMethod.
/**
* Add new Method Signature definition for Generated Type Builder and
* returns Method Signature Builder for specifying all Method parameters. <br>
* Name of Method cannot be <code>null</code>, if it is <code>null</code>
* the method SHOULD throw {@link IllegalArgumentException} <br>
* By <i>Default</i> the MethodSignatureBuilder SHOULD be pre-set as
* {@link MethodSignatureBuilder#setAbstract(boolean)},
* {TypeMemberBuilder#setFinal(boolean)} and
* {TypeMemberBuilder#setAccessModifier(boolean)}
*
* @param name
* Name of Method
* @return <code>new</code> instance of Method Signature Builder.
*/
@Override
public final MethodSignatureBuilder addMethod(final String name) {
final MethodSignatureBuilder builder = super.addMethod(name);
builder.setAbstract(false);
return builder;
}
use of org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder in project mdsal by opendaylight.
the class AbstractGeneratedTypeBuilder method addMethod.
@Override
public MethodSignatureBuilder addMethod(final String name) {
checkArgument(name != null, "Name of method cannot be null!");
final MethodSignatureBuilder builder = new MethodSignatureBuilderImpl(name);
builder.setAccessModifier(AccessModifier.PUBLIC);
builder.setAbstract(true);
this.methodDefinitions = LazyCollections.lazyAdd(this.methodDefinitions, builder);
return builder;
}
use of org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder in project mdsal by opendaylight.
the class GeneratedTypeBuilderTest method addMethodTest.
@Test
public void addMethodTest() {
GeneratedTypeBuilder generatedTypeBuilder = new CodegenGeneratedTypeBuilder(JavaTypeName.create("my.package", "MyName"));
MethodSignatureBuilder methodBuilder = generatedTypeBuilder.addMethod("myMethodName");
MethodSignatureBuilder methodBuilder2 = generatedTypeBuilder.addMethod("myMethodName2");
assertNotNull(methodBuilder);
assertNotNull(methodBuilder2);
assertTrue(generatedTypeBuilder.containsMethod("myMethodName"));
assertTrue(generatedTypeBuilder.containsMethod("myMethodName2"));
assertFalse(generatedTypeBuilder.containsMethod("myMethodName3"));
GeneratedType instance = generatedTypeBuilder.build();
List<MethodSignature> methodDefinitions = instance.getMethodDefinitions();
assertEquals(2, methodDefinitions.size());
assertTrue(methodDefinitions.contains(methodBuilder.toInstance(instance)));
assertTrue(methodDefinitions.contains(methodBuilder2.toInstance(instance)));
assertFalse(methodDefinitions.contains(new MethodSignatureBuilderImpl("myMethodName3").toInstance(instance)));
}
use of org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder in project mdsal by opendaylight.
the class AbstractExplicitGenerator method constructGetter.
final MethodSignatureBuilder constructGetter(final GeneratedTypeBuilderBase<?> builder, final Type returnType, final String methodName) {
final MethodSignatureBuilder getMethod = builder.addMethod(methodName).setReturnType(returnType);
annotateDeprecatedIfNecessary(getMethod);
statement.findFirstEffectiveSubstatementArgument(DescriptionEffectiveStatement.class).map(TypeMemberComment::referenceOf).ifPresent(getMethod::setComment);
return getMethod;
}
use of org.opendaylight.mdsal.binding.model.api.type.builder.MethodSignatureBuilder in project mdsal by opendaylight.
the class Generator method defineImplementedInterfaceMethod.
private static MethodSignatureBuilder defineImplementedInterfaceMethod(final GeneratedTypeBuilder typeBuilder, final Type classType) {
final MethodSignatureBuilder ret = typeBuilder.addMethod(BindingMapping.DATA_CONTAINER_IMPLEMENTED_INTERFACE_NAME).setAccessModifier(AccessModifier.PUBLIC).setReturnType(classType(classType));
ret.addAnnotation(OVERRIDE_ANNOTATION);
return ret;
}
Aggregations