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:
adrian.f.cole 2009-06-04 04:45:12 +00:00
parent 90728e65b1
commit 98fe4e9955
13 changed files with 584 additions and 351 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
} }

View File

@ -28,30 +28,39 @@ package org.jclouds.codegen.model;
* @author James Murty * @author James Murty
*/ */
public class Parameter { public class Parameter {
private String name; private String javaName;
private String type; private String name;
private String javaType; private String type;
private String param; private String javaType;
private String desc; private String param;
private String desc;
public String getName() { public String getName() {
return name; return name;
} }
public String getType() { public String getType() {
return type; return type;
} }
public String getJavaType() { public String getJavaType() {
return javaType; return javaType;
} }
public String getParam() { public String getParam() {
return param; return param;
} }
public String getDesc() { public String getDesc() {
return desc; return desc;
} }
public void setJavaName(String javaName) {
this.javaName = javaName;
}
public String getJavaName() {
return javaName;
}
} }

View File

@ -28,25 +28,34 @@ package org.jclouds.codegen.model;
* @author James Murty * @author James Murty
*/ */
public class ResponseField { public class ResponseField {
private String desc; private String javaName;
private String name; private String desc;
private String type; private String name;
private String javaType; private String type;
private String javaType;
public String getDesc() { public String getDesc() {
return desc; return desc;
} }
public String getName() { public String getName() {
return name; return name;
} }
public String getType() { public String getType() {
return type; return type;
} }
public String getJavaType() { public String getJavaType() {
return javaType; return javaType;
} }
public void setJavaName(String javaName) {
this.javaName = javaName;
}
public String getJavaName() {
return javaName;
}
} }

View File

@ -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

View File

@ -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}

View File

@ -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);
} }

View File

@ -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}

View File

@ -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)
*/ */

View File

@ -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};

View File

@ -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};