'use strict';

class DvnDataAdapter {
  constructor(labelFieldId, valueFieldId) {
    this.labelFieldId = labelFieldId;
    this.labelFieldIds = labelFieldId.split('+');
    this.valueFieldId = valueFieldId;
  }
  label(item) {
    if (this.labelFieldIds.length > 0) {
      return this.labelFieldIds.map(fieldId => item[fieldId]).join(' ');
    }
    return item[this.labelFieldId];
  }
  value(item) {
    return item[this.valueFieldId];
  }
}

exports.DvnDataAdapter = DvnDataAdapter;
