/** * Remove attributes of this model. * @param attrs the attribute names of the model * @return this model */ public M remove(String... attrs) { if (attrs != null) for (String a : attrs) { this.attrs.remove(a); this.getModifyFlag().remove(a); } return (M)this; }
/** * Keep attributes of this model and remove other attributes. * @param attrs the attribute names of the model * @return this model */ public M keep(String... attrs) { if (attrs != null && attrs.length > 0) { Config config = getConfig(); Map newAttrs = config.containerFactory.getAttrsMap(); // new HashMap(attrs.length); Set newModifyFlag = config.containerFactory.getModifyFlagSet(); // new HashSet(); for (String a : attrs) { if (this.attrs.containsKey(a)) // prevent put null value to the newColumns newAttrs.put(a, this.attrs.get(a)); if (this.getModifyFlag().contains(a)) newModifyFlag.add(a); } this.attrs = newAttrs; this.modifyFlag = newModifyFlag; } else { this.attrs.clear(); this.getModifyFlag().clear(); } return (M)this; }
/**
* Remove attributes of this model.
* @param attrs the attribute names of the model
* @return this model
*/
public M remove(String... attrs) {
if (attrs != null)
for (String a : attrs) {
this.attrs.remove(a);
this.getModifyFlag().remove(a);
}
return (M)this;
}
/**
* Keep attributes of this model and remove other attributes.
* @param attrs the attribute names of the model
* @return this model
*/
public M keep(String... attrs) {
if (attrs != null && attrs.length > 0) {
Config config = getConfig();
Map newAttrs = config.containerFactory.getAttrsMap(); // new HashMap(attrs.length);
Set newModifyFlag = config.containerFactory.getModifyFlagSet(); // new HashSet();
for (String a : attrs) {
if (this.attrs.containsKey(a)) // prevent put null value to the newColumns
newAttrs.put(a, this.attrs.get(a));
if (this.getModifyFlag().contains(a))
newModifyFlag.add(a);
}
this.attrs = newAttrs;
this.modifyFlag = newModifyFlag;
}
else {
this.attrs.clear();
this.getModifyFlag().clear();
}
return (M)this;
}