我有一个名为 PaymentFrequency 的枚举:
public enum PaymentFrequency {
D("Daily"),
W("Weekly"),
M("Monthly"),
Y("Yearly");
private final String description;
PaymentFrequency(final String description) {
this.description = description;
}
public String getDescription() {
return description;
}
}
现在,如果我在我的 bean 中这样做:
private PaymentFrequency[] paymentPeriods = PaymentFrequency.values();
public PaymentFrequency[] getPaymentPeriods() {
return paymentPeriods;
}
public void setPaymentPeriods(PaymentFrequency[] paymentPeriods) {
this.paymentPeriods = paymentPeriods;
}
我将从我的枚举中获得所有值。我怎样才能只得到值W和M?