Code Monkey home page Code Monkey logo

jclouds-bean-cleaner's Introduction

Utility for re-writing Java domain objects

Configured to output http://jclouds.org beans, usage is as follows::

java -jar cleaner-1.0.jar -format [format] [sourcepath] [classpath]

Where:

  • [format] is one of json (default), jaxb, json_serialize (json plus @Named fields for serialization), mixed (json_serialize & jaxb) or minimal
  • [sourcepath] points to the folder containing the source for your beans
  • [classpath] is something to be added to the classpath of the run (e.g. target/classes or "target/classes:../somewhere").

Examples of each Format

NOTES

  • regrettably, if classpath is incorrect the results will have Object references in place of the expected class.
  • for mixed mode you need to provide the jaxb annotations in the input (the jclouds json annotations will be added)
  • it is generally possible to cycle through the usual forms of beans, picking up @Named, @SerializedName, @XmlElement, etc. to determine serialized names (for 'mixed' this is helpful)
  • in the case of @ConstructorProperties on a constructor and no field annotations the cleaner will try to work things out (assuming the parameters to the constructor match the field names!)

RUNNING THE CLEANER

To regenerate the beans for nova on my laptop I would do as follows::

Adam-Lowes-MacBook-Pro:nova aplowe$ java -jar ~/src/jclouds-bean-cleaner/target/cleaner-1.0.jar -format json_serialize src/main/java/org/jclouds/openstack/nova/domain target/classes/
INFO: Loading source file /Users/aplowe/src/jclouds-aplowe2/apis/nova/src/main/java/org/jclouds/openstack/nova/domain/AbsoluteLimit.java...
...
INFO: Processing Server writing to /Users/aplowe/src/jclouds-aplowe2/apis/nova/target/generated-sources/cleanbeans/org/jclouds/openstack/nova/domain/Server.java
INFO: Javadoc returned successfully
INFO: You passed the following arguments: -format json_serialize src/main/java/org/jclouds/openstack/nova/domain target/classes/
Adam-Lowes-MacBook-Pro:nova aplowe$ 

License

Copyright (C) 2012-2013 Cloudsoft Corporation.

Licensed under the Apache License, Version 2.0

jclouds-bean-cleaner's People

Contributors

aplowe avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

grkvlt aledsage

jclouds-bean-cleaner's Issues

immutable parameterized constructor

Especially when creating immutable objects, we need to have parameterized constructors. In the case of google gson, we will want to annotate the parameterized constructor with @Inject where all parameters have @nAmed annotations corresponding to either the field name or the serialized name of the field. Moreover, it would be best to generate the 'copy-in' boilerplate of collections. Ex. A parameter of type Set would be assigned by this.field = immutableset.copyof(checknotnull(field, "field"));

Requiring a json parser to pass in an instance of an abstract builder is not going to work without very custom json/yaml.. parsers, so let's change a bit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.