mirror of https://github.com/apache/jclouds.git
Issue 36: some progress towards merging object models
git-svn-id: http://jclouds.googlecode.com/svn/trunk@891 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
90728e65b1
commit
98fe4e9955
|
@ -0,0 +1,79 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ public abstract class BaseBean {
|
||||||
private String packageName;
|
private String packageName;
|
||||||
private String awsType;
|
private String awsType;
|
||||||
private String javaType;
|
private String javaType;
|
||||||
|
private String javaName;
|
||||||
|
|
||||||
public String getJavaType() {
|
public String getJavaType() {
|
||||||
return javaType;
|
return javaType;
|
||||||
|
@ -49,4 +50,12 @@ public abstract class BaseBean {
|
||||||
return awsType;
|
return awsType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setJavaName(String javaName) {
|
||||||
|
this.javaName = javaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaName() {
|
||||||
|
return javaName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ package org.jclouds.codegen.model;
|
||||||
* @author James Murty
|
* @author James Murty
|
||||||
*/
|
*/
|
||||||
public class Parameter {
|
public class Parameter {
|
||||||
|
private String javaName;
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
private String javaType;
|
private String javaType;
|
||||||
|
@ -54,4 +55,12 @@ public class Parameter {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setJavaName(String javaName) {
|
||||||
|
this.javaName = javaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaName() {
|
||||||
|
return javaName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ package org.jclouds.codegen.model;
|
||||||
* @author James Murty
|
* @author James Murty
|
||||||
*/
|
*/
|
||||||
public class ResponseField {
|
public class ResponseField {
|
||||||
|
private String javaName;
|
||||||
private String desc;
|
private String desc;
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
|
@ -49,4 +50,12 @@ public class ResponseField {
|
||||||
return javaType;
|
return javaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setJavaName(String javaName) {
|
||||||
|
this.javaName = javaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaName() {
|
||||||
|
return javaName;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,8 @@ public class CodeGenerator {
|
||||||
"BaseEC2RequestOptions<EC2RequestOptions>") == -1) {
|
"BaseEC2RequestOptions<EC2RequestOptions>") == -1) {
|
||||||
generateClassFile(command.getOptions(), OPTIONS_TEMPLATE_FILENAME);
|
generateClassFile(command.getOptions(), OPTIONS_TEMPLATE_FILENAME);
|
||||||
}
|
}
|
||||||
if (command.getResponse() != null) {
|
if (command.getResponse() != null
|
||||||
|
&& !command.getResponse().getJavaType().equals("Boolean")) {
|
||||||
generateClassFile(command.getResponse(), RESPONSE_TEMPLATE_FILENAME);
|
generateClassFile(command.getResponse(), RESPONSE_TEMPLATE_FILENAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,6 +29,9 @@ package ${bean.packageName};
|
||||||
[#if bean.packageName != rootPackageName]
|
[#if bean.packageName != rootPackageName]
|
||||||
import ${rootPackageName}.*;
|
import ${rootPackageName}.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -49,14 +52,14 @@ public class ${shortClassName} {
|
||||||
*
|
*
|
||||||
* ${field.desc}
|
* ${field.desc}
|
||||||
*/
|
*/
|
||||||
private ${field.javaType} ${field.name?uncap_first};
|
private ${field.javaType} ${field.javaName?uncap_first};
|
||||||
|
|
||||||
[/#list]
|
[/#list]
|
||||||
|
|
||||||
[#-- Print get/set --]
|
[#-- Print get/set --]
|
||||||
[#list bean.parameters![] as field]
|
[#list bean.parameters![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return ${field.desc}
|
* @return ${field.desc}
|
||||||
|
|
|
@ -34,6 +34,8 @@ import ${bean.response.packageName}.*;
|
||||||
import ${bean.options.packageName}.*;
|
import ${bean.options.packageName}.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
import org.jclouds.aws.reference.AWSConstants;
|
import org.jclouds.aws.reference.AWSConstants;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.http.commands.callables.xml.ParseSax;
|
import org.jclouds.http.commands.callables.xml.ParseSax;
|
||||||
|
|
||||||
|
@ -61,18 +63,17 @@ public class ${shortClassName} extends HttpFutureCommand<${RT}> {
|
||||||
@Named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY) String awsSecretAccessKey,
|
@Named(AWSConstants.PROPERTY_AWS_SECRETACCESSKEY) String awsSecretAccessKey,
|
||||||
ParseSax<${RT}> callable,
|
ParseSax<${RT}> callable,
|
||||||
[#if bean.options.javaType?? ]
|
[#if bean.options.javaType?? ]
|
||||||
@Assisted ${bean.options.javaType} options,
|
@Assisted ${bean.options.javaType} options
|
||||||
[#else]
|
[#else]
|
||||||
@Assisted BaseEC2RequestOptions<EC2RequestOptions> options,
|
@Assisted BaseEC2RequestOptions<EC2RequestOptions> options
|
||||||
[/#if]
|
[/#if]
|
||||||
[#list bean.parameters![] as param]
|
[#list bean.parameters![] as param]
|
||||||
@Assisted ${param.javaType} ${param.name?uncap_first}[#rt]
|
,@Assisted ${param.javaType} ${param.javaName?uncap_first}[#rt]
|
||||||
[#if param_has_next],[#else])[/#if]
|
[/#list]) {
|
||||||
[/#list] {
|
|
||||||
super("GET",
|
super("GET",
|
||||||
"/" + options
|
"/" + options
|
||||||
[#list bean.parameters![] as param]
|
[#list bean.parameters![] as param]
|
||||||
.with${param.name?cap_first}(${param.name?uncap_first})
|
.with${param.javaName?cap_first}(${param.javaName?uncap_first})
|
||||||
[/#list]
|
[/#list]
|
||||||
.signWith(awsAccessKeyId,awsSecretAccessKey).buildQueryString(), callable);
|
.signWith(awsAccessKeyId,awsSecretAccessKey).buildQueryString(), callable);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ package ${bean.packageName};
|
||||||
[#if bean.packageName != rootPackageName]
|
[#if bean.packageName != rootPackageName]
|
||||||
import ${rootPackageName}.*;
|
import ${rootPackageName}.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -49,14 +51,14 @@ public class ${shortClassName} {
|
||||||
*
|
*
|
||||||
* ${field.desc}
|
* ${field.desc}
|
||||||
*/
|
*/
|
||||||
private ${field.javaType} ${field.name?uncap_first};
|
private ${field.javaType} ${field.javaName?uncap_first};
|
||||||
|
|
||||||
[/#list]
|
[/#list]
|
||||||
|
|
||||||
[#-- Print get/set --]
|
[#-- Print get/set --]
|
||||||
[#list bean.parameters![] as field]
|
[#list bean.parameters![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return ${field.desc}
|
* @return ${field.desc}
|
||||||
|
|
|
@ -29,6 +29,8 @@ package ${bean.packageName};
|
||||||
[#if bean.packageName != rootPackageName]
|
[#if bean.packageName != rootPackageName]
|
||||||
import ${rootPackageName}.*;
|
import ${rootPackageName}.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.jclouds.aws.ec2.commands.options.BaseEC2RequestOptions;
|
import org.jclouds.aws.ec2.commands.options.BaseEC2RequestOptions;
|
||||||
|
|
||||||
|
@ -62,8 +64,8 @@ public class ${shortClassName} extends
|
||||||
}
|
}
|
||||||
|
|
||||||
[#list bean.parameters![] as field]
|
[#list bean.parameters![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ${shortClassName}#with${upperName}(String)
|
* @see ${shortClassName}#with${upperName}(String)
|
||||||
|
@ -86,8 +88,8 @@ public class ${shortClassName} extends
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
[#list bean.parameters![] as field]
|
[#list bean.parameters![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
/**
|
/**
|
||||||
* @see ${shortClassName}#withId(String)
|
* @see ${shortClassName}#withId(String)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,8 @@ package ${bean.packageName};
|
||||||
import ${rootPackageName}.domain.*;
|
import ${rootPackageName}.domain.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -48,14 +49,14 @@ public class ${shortClassName} {
|
||||||
[#-- Print fields --]
|
[#-- Print fields --]
|
||||||
[#list bean.fields![] as field]
|
[#list bean.fields![] as field]
|
||||||
|
|
||||||
private ${field.javaType} ${field.name?uncap_first};
|
private ${field.javaType} ${field.javaName?uncap_first};
|
||||||
|
|
||||||
[/#list]
|
[/#list]
|
||||||
|
|
||||||
[#-- Print get/set --]
|
[#-- Print get/set --]
|
||||||
[#list bean.fields![] as field]
|
[#list bean.fields![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
|
|
||||||
public ${field.javaType} get${upperName}(){
|
public ${field.javaType} get${upperName}(){
|
||||||
return this.${lowerName};
|
return this.${lowerName};
|
||||||
|
|
|
@ -30,7 +30,8 @@ package ${bean.packageName};
|
||||||
import ${rootPackageName}.*;
|
import ${rootPackageName}.*;
|
||||||
[/#if]
|
[/#if]
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -48,14 +49,14 @@ public class ${shortClassName} {
|
||||||
[#-- Print fields --]
|
[#-- Print fields --]
|
||||||
[#list bean.fields![] as field]
|
[#list bean.fields![] as field]
|
||||||
|
|
||||||
private ${field.javaType} ${field.name?uncap_first};
|
private ${field.javaType} ${field.javaName?uncap_first};
|
||||||
|
|
||||||
[/#list]
|
[/#list]
|
||||||
|
|
||||||
[#-- Print get/set --]
|
[#-- Print get/set --]
|
||||||
[#list bean.fields![] as field]
|
[#list bean.fields![] as field]
|
||||||
[#assign lowerName = field.name?uncap_first]
|
[#assign lowerName = field.javaName?uncap_first]
|
||||||
[#assign upperName = field.name?cap_first]
|
[#assign upperName = field.javaName?cap_first]
|
||||||
|
|
||||||
public ${field.javaType} get${upperName}(){
|
public ${field.javaType} get${upperName}(){
|
||||||
return this.${lowerName};
|
return this.${lowerName};
|
||||||
|
|
Loading…
Reference in New Issue