2 * Copyright (c) 2013 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
8 package org.opendaylight.yangtools.sal.java.api.generator;
12 * Transformator of the data from the virtual form to JAVA source code. The result source code represents JAVA interface. For
13 * generating of the source code is used the template written in XTEND language.
16 import org.opendaylight.yangtools.sal.binding.model.api.CodeGenerator;
17 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
18 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
19 import org.opendaylight.yangtools.sal.binding.model.api.Type;
21 public final class InterfaceGenerator implements CodeGenerator {
24 public boolean isAcceptable(Type type) {
25 return type instanceof GeneratedType && !(type instanceof GeneratedTransferObject);
29 * Generates JAVA source code for generated type <code>Type</code>. The code
30 * is generated according to the template source code template which is
31 * written in XTEND language.
34 public String generate(Type type) {
35 if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
36 final GeneratedType genType = (GeneratedType) type;
37 final InterfaceTemplate interfaceTemplate = new InterfaceTemplate(genType);
38 return interfaceTemplate.generate();
44 public String getUnitName(Type type) {
45 return type.getName();