Search in sources :

Example 1 with MDLanguage

use of com.github._1c_syntax.mdclasses.mdo.MDLanguage in project mdclasses by 1c-syntax.

the class PairConverter method unmarshal.

@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    if ("languages".equals(reader.getNodeName())) {
        var uuid = reader.getAttribute("uuid");
        var language = (MDLanguage) context.convertAnother(new MDLanguage(), MDLanguage.class);
        language.setUuid(uuid);
        language.setMdoReference(new MDOReference(language));
        return Either.right(language);
    } else if (reader.getValue().contains(".")) {
        // уже лежит имя
        return Either.left(reader.getValue());
    } else {
        var type = MDOType.fromValue(reader.getNodeName());
        return type.map(mdoType -> Either.left(mdoType.getName() + "." + reader.getValue())).orElseGet(() -> Either.left(reader.getNodeName() + "." + reader.getValue()));
    }
}
Also used : MDOReference(com.github._1c_syntax.mdclasses.mdo.support.MDOReference) MDLanguage(com.github._1c_syntax.mdclasses.mdo.MDLanguage)

Aggregations

MDLanguage (com.github._1c_syntax.mdclasses.mdo.MDLanguage)1 MDOReference (com.github._1c_syntax.mdclasses.mdo.support.MDOReference)1