bt.bencoding.model.BEMapModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bt-bencoding Show documentation
Show all versions of bt-bencoding Show documentation
Library for parsing, encoding and validating bencoded documents in Java
package bt.bencoding.model;
import bt.bencoding.BEType;
import bt.bencoding.model.rule.Rule;
import java.util.List;
import java.util.Map;
class BEMapModel extends BaseBEObjectModel {
private Map entriesModel;
BEMapModel(Map entriesModel, List rules) {
super(rules);
this.entriesModel = entriesModel;
}
@Override
public BEType getType() {
return BEType.MAP;
}
@Override
protected ValidationResult afterValidate(ValidationResult validationResult, Object object) {
if (object != null) {
Map,?> map = (Map,?>) object;
for (Map.Entry entryModel : entriesModel.entrySet()) {
String key = entryModel.getKey();
entryModel.getValue().validate(map.get(key)).getMessages()
.forEach(validationResult::addMessage);
}
}
return validationResult;
}
}