2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.mdsal.binding2.java.api.generator;
11 import com.google.common.annotations.Beta;
12 import org.opendaylight.mdsal.binding2.java.api.generator.renderers.BuilderRenderer;
13 import org.opendaylight.mdsal.binding2.model.api.CodeGenerator;
14 import org.opendaylight.mdsal.binding2.model.api.GeneratedTransferObject;
15 import org.opendaylight.mdsal.binding2.model.api.GeneratedType;
16 import org.opendaylight.mdsal.binding2.model.api.Type;
17 import org.opendaylight.mdsal.binding2.model.api.UnitName;
18 import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentable;
19 import org.opendaylight.mdsal.binding.javav2.spec.structural.Augmentation;
20 import org.opendaylight.yangtools.concepts.Identifier;
23 * Transformer of the data from the virtual form to JAVA programming language.
24 * The result source code represent java class. For generation of the source
25 * code is used the template written in Twirl (Scala based) language.
28 public final class BuilderGenerator implements CodeGenerator {
31 public String generate(Type type) {
32 if ((type instanceof GeneratedType) && !(type instanceof GeneratedTransferObject)) {
33 final GeneratedType genType = (GeneratedType) type;
34 return new BuilderRenderer(genType).generateTemplate();
41 public boolean isAcceptable(Type type) {
42 if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
43 for (Type t : ((GeneratedType) type).getImplements()) {
44 // "rpc" and "grouping" elements do not implement Augmentable
45 if (t.getFullyQualifiedName().equals(Augmentable.class.getName())) {
47 } else if (t.getFullyQualifiedName().equals(Augmentation.class.getName())) {
57 public Identifier getUnitName(Type type) {
58 return new UnitName(type.getName());