All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bt.bencoding.model.BEMapModel Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy