Skip to content

Instantly share code, notes, and snippets.

@tonussi
Last active August 29, 2015 13:56
Show Gist options
  • Save tonussi/9164192 to your computer and use it in GitHub Desktop.
Save tonussi/9164192 to your computer and use it in GitHub Desktop.
Method Naming Confusion Problem
@Entity
public class Vehicle {
private Double price;
private String pricestring;
public Double getPrice() {
return price;
}
public void setPricestring(String pricestring) {
this.pricestring = pricestring;
}
public void setPrice(Double price) {
this.price = price;
if (price < 0 || price.equals(null))
this.price = 0D;
}
public String getPricestring() {
/*
* @stringformat: ddd.ddd,cc
*/
this.pricestring = this.price + "";
if (getPrice().intValue() % 1000000 == getPrice().intValue()) {
this.pricestring = this.pricestring.substring(0, 2).concat(".")
.concat(this.pricestring.substring(2, this.pricestring.indexOf('.')))
.concat(",")
.concat(this.pricestring.substring(this.pricestring.indexOf('.')));
} else if (getPrice().intValue() % 100000 == getPrice().intValue()) {
this.pricestring = this.pricestring.substring(0, 1).concat(".")
.concat(this.pricestring.substring(1, this.pricestring.indexOf('.')))
.concat(",")
.concat(this.pricestring.substring(this.pricestring.indexOf('.')));
} else if (getPrice().intValue() % 10000 == getPrice().intValue()) {
this.pricestring = this.pricestring.substring(0, 0).concat(".")
.concat(this.pricestring.substring(1, this.pricestring.indexOf('.')))
.concat(",")
.concat(this.pricestring.substring(this.pricestring.indexOf('.')));
} else if (getPrice().intValue() % 1000 == getPrice().intValue()) {
this.pricestring = this.pricestring
.substring(0, this.pricestring.indexOf('.')).concat(",")
.concat(this.pricestring.substring(this.pricestring.indexOf('.')));
} else if (getPrice().intValue() % 100 == getPrice().intValue()) {
this.pricestring = this.pricestring
.substring(0, this.pricestring.indexOf('.')).concat(",")
.concat(this.pricestring.substring(this.pricestring.indexOf('.')));
} else {
this.pricestring = "SEM_VALOR";
}
return this.pricestring;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment