📄 productattribute.java
字号:
package com.bluesky.elecall.domain;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class ProductAttribute {
private long id;
private String name;
//if we use the local 'name', then the 'type' is no use
private ProductAttributeType type;
private String value;
private Product product;
public ProductAttribute(){
}
public ProductAttribute(String name,String value){
this.name=name;
this.value=value;
}
public boolean validate(){
if(name==null || value == null)
return false;
if(name.trim().length()==0 || value.trim().length()==0)
return false;
return true;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ProductAttributeType getType() {
return type;
}
public void setType(ProductAttributeType type) {
this.type = type;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static ProductAttribute getSample(){
String[] colorOptions = new String[]{"黑色","红色","白色","黄色","绿色"};
String[] sizeOptions = new String[]{"10cm","20cm","30cm","40cm","50cm"};
String[] voltOptions = new String[]{"100V","200V","300V","400V","500V"};
String[] currentOptions = new String[]{"1A","2A","3A","4A","5A"};
String[] weightOptions = new String[]{"1kg","2kg","3kg","4kg","5kg"};
Map options = new HashMap<String,String>();
options.put("颜色", colorOptions);
options.put("尺寸", sizeOptions);
options.put("电压", voltOptions);
options.put("电流", currentOptions);
options.put("重量", weightOptions);
Random r = new Random();
String name = (String)options.keySet().toArray()[r.nextInt(options.size())];
String[] values = (String[])options.get(name);
String value = values[r.nextInt(values.length)];
ProductAttribute pa = new ProductAttribute(name, value);
return pa;
}
public String toString(){
return String.format("%s=%s", name,value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -