code: /****************************************************************************
  
      ePMC - an extensible probabilistic model checker
      Copyright (C) 2017
  
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
   *****************************************************************************/
  
  package epmc.jani.model;
  
  import java.util.Collections;
  import java.util.LinkedHashMap;
  import java.util.Map;
  import java.util.Map.Entry;
  
  import javax.json.Json;
  import javax.json.JsonObject;
  import javax.json.JsonObjectBuilder;
  import javax.json.JsonValue;
  
  import epmc.util.UtilJSON;
  
  public final class Metadata implements JANINode {
      Map<String,String> values = new LinkedHashMap<>();
      private ModelJANI model;
  
      @Override
      public void setModel(ModelJANI model) {
          this.model = model;
      }
  
      @Override
      public ModelJANI getModel() {
          return model;
      }
  
      @Override
      public JANINode parse(JsonValue value) {
          assert model != null;
          assert value != null;
          JsonObject object = UtilJSON.toObjectString(value);
          for (Entry<String, JsonValue> entry : object.entrySet()) {
              values.put(entry.getKey(), value.toString());
          }
          return this;
      }
  
      @Override
      public JsonValue generate() {
          JsonObjectBuilder builder = Json.createObjectBuilder();
          for (Entry<String, String> entry : values.entrySet()) {
              builder.add(entry.getKey(), entry.getValue());
          }
          return builder.build();
      }
  
      public Map<String,String> getValues() {
          return Collections.unmodifiableMap(values);
      }
  
      public void put(String key, String value) {
          values.put(key, value);
      }
  
      public String get(String key) {
          return values.get(key);
      }
  }
  