diff options
Diffstat (limited to 'quantum-client/src/main/java/com/woorea/openstack/quantum/api/query')
-rw-r--r-- | quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java index 2511b0c..1ba1bb6 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java @@ -26,71 +26,71 @@ import com.woorea.openstack.base.client.OpenStackRequest; public class AbsOpenStackCmd<T> extends OpenStackRequest<T> { - private T query; + private T query; - protected AbsOpenStackCmd(T query) - { - this.setQuery(query); - } + protected AbsOpenStackCmd(T query) + { + this.setQuery(query); + } - /** - * @param query the query to set - */ - public void setQuery(T query) { - this.query = query; - } + /** + * @param query the query to set + */ + public void setQuery(T query) { + this.query = query; + } - /** - * @return the query - */ - public T getQuery() { - return query; - } + /** + * @return the query + */ + public T getQuery() { + return query; + } - private String getFieldValue(Field field, T target) - { - try { - field.setAccessible(true); - Object obj = field.get(target); - if (obj == null) - return null; - return obj.toString(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + private String getFieldValue(Field field, T target) + { + try { + field.setAccessible(true); + Object obj = field.get(target); + if (obj == null) + return null; + return obj.toString(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } - private Map<String, String> getObjectParamMap(T target) - { - Map<String, String> resultMap = new HashMap<>(); - if (target == null) - return resultMap; + private Map<String, String> getObjectParamMap(T target) + { + Map<String, String> resultMap = new HashMap<>(); + if (target == null) + return resultMap; - Field[] paramMap = target.getClass().getDeclaredFields(); - for (Field field : paramMap) { - String resultName = field.getName(); - String value = getFieldValue(field, target); - if (value != null) { - JsonProperty prop = field.getAnnotation(JsonProperty.class); - if (prop != null) { - resultMap.put(prop.value(), getFieldValue(field, target)); - } else { - resultMap.put(resultName, getFieldValue(field, target)); - } - } - } + Field[] paramMap = target.getClass().getDeclaredFields(); + for (Field field : paramMap) { + String resultName = field.getName(); + String value = getFieldValue(field, target); + if (value != null) { + JsonProperty prop = field.getAnnotation(JsonProperty.class); + if (prop != null) { + resultMap.put(prop.value(), getFieldValue(field, target)); + } else { + resultMap.put(resultName, getFieldValue(field, target)); + } + } + } - return resultMap; - } + return resultMap; + } - /* - public WebTarget queryParam(WebTarget target) { - Map<String, String> map = getObjectParamMap(this.query); - for (String fieldName : map.keySet()) { - target = target.queryParam(fieldName, map.get(fieldName)); - } - return target; - } - */ + /* + public WebTarget queryParam(WebTarget target) { + Map<String, String> map = getObjectParamMap(this.query); + for (String fieldName : map.keySet()) { + target = target.queryParam(fieldName, map.get(fieldName)); + } + return target; + } + */ } |