java - Creating immutable view of object using Proxy classes -


i'm newest @ using proxy classes. need create fabric method of immutable view object (musicalinstrument.class) view must throw exception when i'm trying invoke setter , invoking of other methods must transfer object. maybe have got examples or sources can find answers! thanx!

public class musicalinstrument implements serializable {  /**  * id of instrument.  */ private int idinstrument;  /**  * price of instrument.  */ private double price;  /**  * name of instrument.  */ private string name;   public musicalinstrument() { }  public musicalinstrument(int idinstrument, double price, string name) {     this.idinstrument = idinstrument;     this.price = price;     this.name = name; }   public int getidinstrument() {     return idinstrument; }  public void setidinstrument(int idinstrument) {     this.idinstrument = idinstrument; }  public double getprice() {     return price; }  public void setprice(double price) {     this.price = price; }  public string getname() {     return name; }  public void setname(string name) {     this.name = name; }  @override public boolean equals(object o) {     if (this == o) return true;     if (o == null || getclass() != o.getclass()) return false;      musicalinstrument = (musicalinstrument) o;      if (idinstrument != that.idinstrument) return false;     if (double.compare(that.price, price) != 0) return false;     return name != null ? name.equals(that.name) : that.name == null;  }  @override public int hashcode() {     int result;     long temp;     result = idinstrument;     temp = double.doubletolongbits(price);     result = 31 * result + (int) (temp ^ (temp >>> 32));     result = 31 * result + (name != null ? name.hashcode() : 0);     return result; }  @override public string tostring() {     return "musicalinstrument{" +             "idinstrument=" + idinstrument +             ", price=" + price +             ", name='" + name + '\'' +             '}'; } 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -