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.mdsal.binding.java.api.generator;
10 import org.opendaylight.mdsal.binding.model.api.CodeGenerator;
11 import org.opendaylight.mdsal.binding.model.api.Enumeration;
12 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
13 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
14 import org.opendaylight.mdsal.binding.model.api.Type;
16 public final class InterfaceGenerator implements CodeGenerator {
19 public boolean isAcceptable(Type type) {
20 return type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)
21 && !(type instanceof Enumeration);
25 * Generates JAVA source code for generated type <code>Type</code>. The code
26 * is generated according to the template source code template which is
27 * written in XTEND language.
30 public String generate(Type type) {
31 if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
32 final GeneratedType genType = (GeneratedType) type;
33 final InterfaceTemplate interfaceTemplate = new InterfaceTemplate(genType);
34 return interfaceTemplate.generate();
40 public String getUnitName(Type type) {
41 return type.getName();