GithubHelp home page GithubHelp logo

jodaorg / joda-beans Goto Github PK

View Code? Open in Web Editor NEW
142.0 142.0 37.0 3.94 MB

Java library to provide an API for beans and properties.

Home Page: http://www.joda.org/joda-beans/

License: Apache License 2.0

Java 99.94% CSS 0.05% HTML 0.01%
java java-bean joda joda-beans

joda-beans's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

joda-beans's Issues

Method naming in classes like DynamicBean

Unless it contributes to the "Yoda" brand idea, methods like propertyRename() or propertyDefine() should be called renameProperty() or defineProperty() instead.
Following common Java method naming practice and conventions, and also for consistency with other classes in this library(!) like MetaBean.createPropertyMap() rather than MetaBean.propertyMapCreate().

Additional equals/hashCode methods

The autogenerated equals/hashCode calls JodaBeanUtils. For equals, this boxes all primitive numbers, which is inefficient. For hashCode, int/boolean are not handled.

Java 7 generated code should use <> for generics where appropriate

Class definition:

@BeanDefinition
public class JodaBeanExample extends DirectBean {

    @PropertyDefinition
    private Set<String> someStrings;
}

Then autogenerate the rest of the class which creates a builder method:

@Override
public BeanBuilder<? extends JodaBeanExample> builder() {
  return new DirectBeanBuilder<JodaBeanExample>(new JodaBeanExample());
}

In Java 7 this should instead be:

@Override
public BeanBuilder<? extends JodaBeanExample> builder() {
  return new DirectBeanBuilder<>(new JodaBeanExample());
}

Handle classes that are loaded but not initialized

A Class can be loaded without being initialized. This would result in the static initializer not being run, and thus the bean not registering itself with JodaBeanUtils.

Use Class.forName(cls.getName(), true, cls.getClassLoader()) to force initialization.

Add support for bean clone

The clone() method would be a useful addition to all beans. Immutable beans can optimise the implementation.

Generate toString method

The toString method can be generated automatically. Any manually written toString must be respected.

Bean comparison does not match equals

The BeanComparisonError class does not match the bean equals.

  • It needs to use JodaBeanUtils.equals
  • it has a duplicate getClass check that defeats the list/map code
  • the list/map code is better than the equals code wrt embedded arrays

The latter will not be fixed as you'd have to be stupid to put arrays in lists/maps...

More flexible XML parsing wrt Joda-Convert

If a bean is migrated from a normal bean to one that has Joda-Convert annotations, or vice versa, then the parser should still handle it.

If a string is parsed instead of elements, then try it via Joda-Convert.

why not using asm create bytecode at run-time?

hello Stephen:
I think joda-beans is similar but more than (reflectasm)[http://code.google.com/p/reflectasm/] . I have a question that why joda-beans don't use asm to create bytecode at run-time? I think it much easier for user.

Generated getters/setters for deprecated fields only deprecated themselves if field's Deprecated annotation comes after PropertyDefinition

This (with or without the Deprecated annotation)

  /**
   * The field.
   * 
   * @deprecated  Do not use.
   */
  @PropertyDefinition
  @Deprecated
  private String _field;

generates

  /**
   * Gets the field.
   * 
   * @deprecated  Do not use.
   * @return the value of the property
   */
  @Deprecated
  public String getField() {
    return _field;
  }

  /**
   * Sets the field.
   * 
   * @deprecated  Do not use.
   * @param field  the new value of the property
   */
  @Deprecated
  public void setField(String field) {
    this._field = field;
  }

However, this

  /**
   * The field.
   * 
   * @deprecated  Do not use.
   */
  @Deprecated
  @PropertyDefinition
  private String _field;

generates

  /**
   * Gets the field.
   * @return the value of the property
   */
  public String getField() {
    return _field;
  }

  /**
   * Sets the field.
   * @param field  the new value of the property
   */
  public void setField(String field) {
    this._field = field;
  }

Add XML serialization

Allow Joda-Beans to be converted to and from XML using the meta-data knowledge. Focus on a human-readable format wherever possible.

Support Bean implementations with final fields

The builder generated for a Bean assumes the existence of a no-args constructor. This isn't useful for classes with final fields because those fields can never be given sensible values.

A Bean with final fields should require or generate a constructor with parameters for all final fields, possibly using java.util.ConstructorProperties to map them to properties.

Enhance dynamic beans

  • When using a FlexiBean/MapBean builder properties should be automatically created.
  • When querying metaProperty(name) a property should be created
  • add DynamicMetaBean

Derived bean equals() method doesn't call super.equals()

Given the following bean definitions:

@BeanDefinition
public class Base implements Bean {

    @PropertyDefinition
    private String _str;
}

@BeanDefinition
public class Derived extends Base implements Bean {

    @PropertyDefinition
    private int _i;
} 

The following equals() method is generated for Derived

@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (obj != null && obj.getClass() == this.getClass()) {
        Derived other = (Derived) obj;
        return (getI() == other.getI());
    }
    return false;
}

This is incorrect because there's no call to super.equals() even though the superclass contains state.

Derived bean metaclass doesn't extend base metaclass

Given the following bean definitions:

@BeanDefinition
public class Base implements Bean {

    @PropertyDefinition
    private String _str;
}

@BeanDefinition
public class Derived extends Base implements Bean {

    @PropertyDefinition
    private int _i;
}

The generated metaclass for Derived doesn't extend Base.Meta. This means the meta() and metaBean() methods have a return type that's incompatible with the equivalent superclass methods. The derived metaclass also doesn't include the properties from the base metaclass.

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.