mirror of https://github.com/apache/jclouds.git
Issue 36: reorganized and revamped codegen
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1412 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
006fd88ea3
commit
0c5b1b3e0c
106
codegen/pom.xml
106
codegen/pom.xml
|
@ -1,106 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
$HeadURL$ $Revision$ $Date$ Copyright (C) 2009 Adrian Cole
|
||||
<adrian@jclouds.org>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to you under the Apache License, Version
|
||||
2.0 (the "License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0.html Unless required by
|
||||
applicable law or agreed to in writing, software distributed under the
|
||||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||
the specific language governing permissions and limitations under the
|
||||
License.
|
||||
====================================================================
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>jclouds-codegen-project</artifactId>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jclouds-codegen-core</artifactId>
|
||||
<name>jclouds code generator</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>jclouds code generator</description>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://jclouds.googlecode.com/svn/trunk/codegen/core</connection>
|
||||
<developerConnection>scm:svn:https://jclouds.googlecode.com/svn/trunk/codegen/core</developerConnection>
|
||||
<url>http://jclouds.googlecode.com/svn/trunk/codegen/core</url>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>gson</id>
|
||||
<url>http://google-gson.googlecode.com/svn/mavenrepo</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0-rc1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>org.jclouds.codegen.util.CodeGenerator</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,79 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.ec2.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseBean {
|
||||
|
||||
private String type;
|
||||
private String ancestor;
|
||||
private Set<String> see;
|
||||
private String exampleCode;
|
||||
private Set<BeanField> fields;
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setAncestor(String ancestor) {
|
||||
this.ancestor = ancestor;
|
||||
}
|
||||
|
||||
public String getAncestor() {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
public void setSee(Set<String> see) {
|
||||
this.see = see;
|
||||
}
|
||||
|
||||
public Set<String> getSee() {
|
||||
return see;
|
||||
}
|
||||
|
||||
public void setExampleCode(String exampleCode) {
|
||||
this.exampleCode = exampleCode;
|
||||
}
|
||||
|
||||
public String getExampleCode() {
|
||||
return exampleCode;
|
||||
}
|
||||
|
||||
public void setFields(Set<BeanField> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public Set<BeanField> getFields() {
|
||||
return fields;
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.ec2.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BeanField {
|
||||
|
||||
private String ancestor;
|
||||
private String children;
|
||||
private String constraints;
|
||||
private String defaultValue;
|
||||
private String desc;
|
||||
private Map<String, String> valueMap;
|
||||
private String name;
|
||||
private String optional;
|
||||
private String type;
|
||||
|
||||
public void setAncestor(String ancestor) {
|
||||
this.ancestor = ancestor;
|
||||
}
|
||||
|
||||
public String getAncestor() {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
public void setChildren(String children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setConstraints(String constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
public String getConstraints() {
|
||||
return constraints;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setValueMap(Map<String, String> valueMap) {
|
||||
this.valueMap = valueMap;
|
||||
}
|
||||
|
||||
public Map<String, String> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setOptional(String optional) {
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
public String getOptional() {
|
||||
return optional;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
* @author James Murty
|
||||
*/
|
||||
public class API {
|
||||
private List<Package> packages;
|
||||
private Map<String, DomainType> domain;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getPackages().toString();
|
||||
}
|
||||
|
||||
public void setPackages(List<Package> packages) {
|
||||
this.packages = packages;
|
||||
}
|
||||
|
||||
public List<Package> getPackages() {
|
||||
return packages;
|
||||
}
|
||||
|
||||
public void setDomain(Map<String, DomainType> domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public Map<String, DomainType> getDomain() {
|
||||
return domain;
|
||||
}
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
* @author James Murty
|
||||
*/
|
||||
public class Command extends TopLevelType {
|
||||
private TopLevelType options;
|
||||
private TopLevelType handler;
|
||||
private DomainType response;
|
||||
private String description;
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setOptions(TopLevelType options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public TopLevelType getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setHandler(TopLevelType handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public TopLevelType getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void setResponse(DomainType response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public DomainType getResponse() {
|
||||
return response;
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
|
||||
public class DomainType extends Type {
|
||||
|
||||
private String ancestor;
|
||||
|
||||
public void setAncestor(String ancestor) {
|
||||
this.ancestor = ancestor;
|
||||
}
|
||||
|
||||
public String getAncestor() {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Field {
|
||||
|
||||
private String constraints;
|
||||
private String defaultValue;
|
||||
private String desc;
|
||||
private String name;
|
||||
private String javaName;
|
||||
private boolean optional = true;
|
||||
private String type;
|
||||
private String javaType;
|
||||
private Map<String, String> valueMap;
|
||||
|
||||
public void setConstraints(String constraints) {
|
||||
this.constraints = constraints;
|
||||
}
|
||||
|
||||
public String getConstraints() {
|
||||
return constraints;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setValueMap(Map<String, String> valueMap) {
|
||||
this.valueMap = valueMap;
|
||||
}
|
||||
|
||||
public Map<String, String> getValueMap() {
|
||||
return valueMap;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setOptional(boolean optional) {
|
||||
this.optional = optional;
|
||||
}
|
||||
|
||||
public boolean getOptional() {
|
||||
return optional;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setJavaName(String javaName) {
|
||||
this.javaName = javaName;
|
||||
}
|
||||
|
||||
public String getJavaName() {
|
||||
return javaName;
|
||||
}
|
||||
|
||||
public void setJavaType(String javaType) {
|
||||
this.javaType = javaType;
|
||||
}
|
||||
|
||||
public String getJavaType() {
|
||||
return javaType;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author James Murty
|
||||
*/
|
||||
public class Package {
|
||||
private String name;
|
||||
private List<Command> commands;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("{'name':'%1$s', 'commands':%2$s", name, commands);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<Command> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
|
||||
public class TopLevelType extends Type {
|
||||
|
||||
private String ancestor;
|
||||
private String exampleCode;
|
||||
private String exampleHTML;
|
||||
|
||||
public void setAncestor(String ancestor) {
|
||||
this.ancestor = ancestor;
|
||||
}
|
||||
|
||||
public String getAncestor() {
|
||||
return ancestor;
|
||||
}
|
||||
|
||||
public void setExampleCode(String exampleCode) {
|
||||
this.exampleCode = exampleCode;
|
||||
}
|
||||
|
||||
public String getExampleCode() {
|
||||
return exampleCode;
|
||||
}
|
||||
|
||||
public void setExampleHTML(String exampleHTML) {
|
||||
this.exampleHTML = exampleHTML;
|
||||
}
|
||||
|
||||
public String getExampleHTML() {
|
||||
return exampleHTML;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
* JBoss, Home of Professional Open Source.
|
||||
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
|
||||
* as indicated by the @author tags. See the copyright.txt file in the
|
||||
* distribution for a full listing of individual contributors.
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as
|
||||
* published by the Free Software Foundation; either version 2.1 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this software; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jclouds.codegen.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class Type {
|
||||
|
||||
private String packageName;
|
||||
private String name;
|
||||
private String javaName;
|
||||
private Set<String> see;
|
||||
private Set<Field> fields;
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setJavaName(String javaName) {
|
||||
this.javaName = javaName;
|
||||
}
|
||||
|
||||
public String getJavaName() {
|
||||
return javaName;
|
||||
}
|
||||
|
||||
public void setSee(Set<String> see) {
|
||||
this.see = see;
|
||||
}
|
||||
|
||||
public Set<String> getSee() {
|
||||
return see;
|
||||
}
|
||||
|
||||
public void setFields(Set<Field> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
public Set<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.codegen.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.codegen.model.API;
|
||||
import org.jclouds.codegen.model.Command;
|
||||
import org.jclouds.codegen.model.DomainType;
|
||||
import org.jclouds.codegen.model.Package;
|
||||
import org.jclouds.codegen.model.Type;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonParseException;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
|
||||
/**
|
||||
* Converts object models representing AWS API beans into Java classes.
|
||||
* <p>
|
||||
* This implementation is designed to perform the following steps:
|
||||
* <ul>
|
||||
* <li>Parse the JSON object representation produced by the <tt>parse_ec2.pl</tt> perl script</li>
|
||||
* <li>Convert the JSON into Java object models (@see org.jclouds.aws.codegen.models)</li>
|
||||
* <li>Iterate through the Command objects generated above and with each one:
|
||||
* <ul>
|
||||
* <li>Load the <a href="http://freemarker.org/">FreeMarker</a>template file for the given object</li>
|
||||
* <li>Create a package directory to receive the Java file, if necessary</li>
|
||||
* <li>Process the object through the template, producing a Java implementation of the object</li>
|
||||
* <ul></li>
|
||||
*
|
||||
* @author James Murty
|
||||
*/
|
||||
public class CodeGenerator {
|
||||
public final static String COMMAND_TEMPLATE_FILENAME = "Command.ftl";
|
||||
public final static String BEAN_TEMPLATE_FILENAME = "Bean.ftl";
|
||||
public final static String OPTIONS_TEMPLATE_FILENAME = "Options.ftl";
|
||||
public final static String VALUE_TEMPLATE_FILENAME = "Value.ftl";
|
||||
public final static String RESPONSE_TEMPLATE_FILENAME = "Response.ftl";
|
||||
|
||||
private final File targetDirectory;
|
||||
private final String rootPackageName;
|
||||
private final Configuration config;
|
||||
|
||||
public CodeGenerator(String rootPackageName, File targetDirectory) throws IOException {
|
||||
this.rootPackageName = rootPackageName;
|
||||
this.targetDirectory = targetDirectory;
|
||||
|
||||
config = new Configuration();
|
||||
config.setClassForTemplateLoading(this.getClass(), "/templates");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a JSON object model file (as generated by <tt>aws/src/main/bin/parse_ec2.pl</tt>) and
|
||||
* convert it into a Java object graph.
|
||||
*
|
||||
* @param objectModelFile
|
||||
* @return
|
||||
* @throws JsonParseException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public API parseModelFromJSON(File objectModelFile) throws JsonParseException,
|
||||
FileNotFoundException {
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(new FileReader(objectModelFile), API.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a JSON object model file and iterate over the resulting objects generating Java code
|
||||
* files.
|
||||
*
|
||||
* @param objectModelFile
|
||||
* @throws JsonParseException
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
public void generateCode(File objectModelFile) throws JsonParseException, IOException,
|
||||
TemplateException {
|
||||
API model = parseModelFromJSON(objectModelFile);
|
||||
|
||||
for (Package pkg : model.getPackages()) {
|
||||
for (Command command : pkg.getCommands()) {
|
||||
generateClassFile(command, COMMAND_TEMPLATE_FILENAME);
|
||||
|
||||
if (command.getHandler() != null) {
|
||||
generateClassFile(command.getHandler(), BEAN_TEMPLATE_FILENAME);
|
||||
}
|
||||
if (command.getOptions() != null
|
||||
&& command.getOptions().getJavaName().indexOf(
|
||||
"BaseEC2RequestOptions<EC2RequestOptions>") == -1) {
|
||||
generateClassFile(command.getOptions(), OPTIONS_TEMPLATE_FILENAME);
|
||||
}
|
||||
if (command.getResponse() != null
|
||||
&& !command.getResponse().getJavaName().equals("Boolean")) {
|
||||
generateClassFile(command.getResponse(), RESPONSE_TEMPLATE_FILENAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (DomainType value : model.getDomain().values()) {
|
||||
generateClassFile(value, VALUE_TEMPLATE_FILENAME);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Java code file for the given object model bean, using the given template name as
|
||||
* the basis for the Java class.
|
||||
*
|
||||
* @param bean
|
||||
* @param templateFileName
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
public void generateClassFile(Type bean, String templateFileName) throws IOException,
|
||||
TemplateException {
|
||||
String shortClassName = bean.getJavaName().substring(
|
||||
bean.getJavaName().lastIndexOf('.') + 1);
|
||||
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
objectMap.put("bean", bean);
|
||||
objectMap.put("rootPackageName", this.rootPackageName);
|
||||
objectMap.put("shortClassName", shortClassName);
|
||||
|
||||
File packageDir = new File(this.targetDirectory, bean.getPackageName().replace('.', '/'));
|
||||
|
||||
if (packageDir.exists() || packageDir.mkdirs()) {
|
||||
File javaFile = new File(packageDir, shortClassName + ".java");
|
||||
FileWriter fw = new FileWriter(javaFile);
|
||||
System.out.println("Generated " + javaFile);
|
||||
applyTemplate(templateFileName, objectMap, fw);
|
||||
} else {
|
||||
throw new IllegalStateException("Unable to create target package directory: " + packageDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the given template to the given object, and output the results into the given writer.
|
||||
*
|
||||
* @param templateFileName
|
||||
* @param objectMap
|
||||
* @param writer
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
public void applyTemplate(String templateFileName, Map<String, Object> objectMap, Writer writer)
|
||||
throws IOException, TemplateException {
|
||||
Template template = this.config.getTemplate(templateFileName, "UTF-8");
|
||||
template.process(objectMap, writer);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 3) {
|
||||
System.out.println("Usage: CodeGenerator objectModelFile rootPackage targetDir");
|
||||
System.out.println(" E.g: CodeGenerator ec2.json org.jclouds.aws.ec2 aws/ec2/api/src");
|
||||
System.exit(1);
|
||||
}
|
||||
File objectModelFile = new File(args[0]);
|
||||
|
||||
String rootPackage = args[1];
|
||||
|
||||
File targetDir = new File(args[2]);
|
||||
|
||||
new CodeGenerator(rootPackage, targetDir).generateCode(objectModelFile);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
[#if bean.packageName != rootPackageName]
|
||||
import ${rootPackageName}.*;
|
||||
[/#if]
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}' />
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
public class ${shortClassName} {
|
||||
|
||||
[#-- Print fields --]
|
||||
[#list bean.parameters![] as field]
|
||||
/**
|
||||
*
|
||||
* ${field.desc}
|
||||
*/
|
||||
private ${field.javaType} ${field.javaName?uncap_first};
|
||||
|
||||
[/#list]
|
||||
|
||||
[#-- Print get/set --]
|
||||
[#list bean.parameters![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
/**
|
||||
*
|
||||
* @return ${field.desc}
|
||||
*/
|
||||
public ${field.javaType} get${upperName}(){
|
||||
return this.${lowerName};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ${lowerName}
|
||||
* ${field.desc}
|
||||
*/
|
||||
public void set${upperName}(${field.javaType} ${lowerName}) {
|
||||
this.${lowerName} = ${lowerName};
|
||||
}
|
||||
|
||||
[/#list]
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
import ${rootPackageName}.domain.*;
|
||||
[#if bean.response??]
|
||||
import ${bean.response.packageName}.*;
|
||||
[/#if]
|
||||
[#if bean.options??]
|
||||
import ${bean.options.packageName}.*;
|
||||
[/#if]
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.http.commands.callables.xml.ParseSax;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import org.jclouds.http.HttpFutureCommand;
|
||||
|
||||
/**
|
||||
*
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}' />
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
[#assign RT = bean.response.javaType]
|
||||
public class ${shortClassName} extends HttpFutureCommand<${RT}> {
|
||||
@Inject
|
||||
public ${shortClassName}(@Named(AWSConstants.PROPERTY_AWS_ACCESSKEYID) String awsAccessKeyId,
|
||||
@Named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY) String awsSecretAccessKey,
|
||||
ParseSax<${RT}> callable,
|
||||
[#if bean.options.javaType?? ]
|
||||
@Assisted ${bean.options.javaType} options
|
||||
[#else]
|
||||
@Assisted BaseEC2RequestOptions<EC2RequestOptions> options
|
||||
[/#if]
|
||||
[#list bean.parameters![] as param]
|
||||
,@Assisted ${param.javaType} ${param.javaName?uncap_first}[#rt]
|
||||
[/#list]) {
|
||||
super("GET",
|
||||
"/" + options
|
||||
[#list bean.parameters![] as param]
|
||||
.with${param.javaName?cap_first}(${param.javaName?uncap_first})
|
||||
[/#list]
|
||||
.signWith(awsAccessKeyId,awsSecretAccessKey).buildQueryString(), callable);
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
[#if bean.packageName != rootPackageName]
|
||||
import ${rootPackageName}.*;
|
||||
[/#if]
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}' />
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
public class ${shortClassName} {
|
||||
|
||||
[#-- Print fields --]
|
||||
[#list bean.parameters![] as field]
|
||||
/**
|
||||
*
|
||||
* ${field.desc}
|
||||
*/
|
||||
private ${field.javaType} ${field.javaName?uncap_first};
|
||||
|
||||
[/#list]
|
||||
|
||||
[#-- Print get/set --]
|
||||
[#list bean.parameters![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
/**
|
||||
*
|
||||
* @return ${field.desc}
|
||||
*/
|
||||
public ${field.javaType} get${upperName}(){
|
||||
return this.${lowerName};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ${lowerName}
|
||||
* ${field.desc}
|
||||
*/
|
||||
public void set${upperName}(${field.javaType} ${lowerName}) {
|
||||
this.${lowerName} = ${lowerName};
|
||||
}
|
||||
|
||||
[/#list]
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
[#if bean.packageName != rootPackageName]
|
||||
import ${rootPackageName}.*;
|
||||
[/#if]
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.aws.ec2.commands.options.BaseEC2RequestOptions;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* <code>
|
||||
* ${bean.example}
|
||||
* </code>
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}'> ${shortClassName}</a>
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
public class ${shortClassName} extends
|
||||
BaseEC2RequestOptions<${shortClassName}> {
|
||||
|
||||
|
||||
public static final ${shortClassName} NONE = new ${shortClassName}();
|
||||
|
||||
static {
|
||||
realClass = ${shortClassName}.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAction() {
|
||||
return "${shortClassName}".replaceAll("Options","");
|
||||
}
|
||||
|
||||
[#list bean.parameters![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
|
||||
/**
|
||||
* @see ${shortClassName}#with${upperName}(String)
|
||||
*/
|
||||
public String get${upperName}() {
|
||||
return parameters.get("${lowerName}");
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: document this bad boy
|
||||
*
|
||||
*/
|
||||
public ${shortClassName} with${upperName}(String ${lowerName}) {
|
||||
encodeAndReplaceParameter("${lowerName}", ${lowerName});
|
||||
return this;
|
||||
}
|
||||
[/#list]
|
||||
|
||||
|
||||
public static class Builder {
|
||||
|
||||
[#list bean.parameters![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
/**
|
||||
* @see ${shortClassName}#withId(String)
|
||||
*/
|
||||
public static ${shortClassName} with${upperName}(String ${lowerName}) {
|
||||
${shortClassName} options = new ${shortClassName}();
|
||||
return options.with${upperName}(${lowerName});
|
||||
}
|
||||
|
||||
[/#list]
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
[#if bean.packageName != rootPackageName]
|
||||
import ${rootPackageName}.domain.*;
|
||||
[/#if]
|
||||
import org.joda.time.DateTime;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}' />
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
public class ${shortClassName} {
|
||||
|
||||
[#-- Print fields --]
|
||||
[#list bean.fields![] as field]
|
||||
|
||||
private ${field.javaType} ${field.javaName?uncap_first};
|
||||
|
||||
[/#list]
|
||||
|
||||
[#-- Print get/set --]
|
||||
[#list bean.fields![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
|
||||
public ${field.javaType} get${upperName}(){
|
||||
return this.${lowerName};
|
||||
}
|
||||
|
||||
public void set${upperName}(${field.javaType} ${lowerName}) {
|
||||
this.${lowerName} = ${lowerName};
|
||||
}
|
||||
|
||||
[/#list]
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
[#ftl]
|
||||
[#--
|
||||
|
||||
|
||||
Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
|
||||
|
||||
====================================================================
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
====================================================================
|
||||
|
||||
--]
|
||||
package ${bean.packageName};
|
||||
|
||||
[#if bean.packageName != rootPackageName]
|
||||
import ${rootPackageName}.*;
|
||||
[/#if]
|
||||
import org.joda.time.DateTime;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
[#list bean.see as see]
|
||||
[#if see?contains(".html")]
|
||||
* @see <a href='${see}' />
|
||||
[#else]
|
||||
* @see ${see}
|
||||
[/#if]
|
||||
[/#list]
|
||||
* @author Generated
|
||||
*/
|
||||
public class ${shortClassName} {
|
||||
|
||||
[#-- Print fields --]
|
||||
[#list bean.fields![] as field]
|
||||
|
||||
private ${field.javaType} ${field.javaName?uncap_first};
|
||||
|
||||
[/#list]
|
||||
|
||||
[#-- Print get/set --]
|
||||
[#list bean.fields![] as field]
|
||||
[#assign lowerName = field.javaName?uncap_first]
|
||||
[#assign upperName = field.javaName?cap_first]
|
||||
|
||||
public ${field.javaType} get${upperName}(){
|
||||
return this.${lowerName};
|
||||
}
|
||||
|
||||
public void set${upperName}(${field.javaType} ${lowerName}) {
|
||||
this.${lowerName} = ${lowerName};
|
||||
}
|
||||
|
||||
[/#list]
|
||||
}
|
Loading…
Reference in New Issue