/**
   * Obtains the value of the specified option's setting in the the given environment's options map,
   * adapting the environment as necessary to the {@link Customizable} API. If not already set,
   * return the option's {@linkplain #getDefaultValue() default value}.
   *
   * @param env an environment on which to query an option
   * @param option an option to query
   * @return value of the option
   * @see Customizable#getValue(Option)
   */
  public static <T> T getValue(
      Environment<?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> env, Option<T> option) {
    Customizable custom = OCLUtil.getAdapter(env, Customizable.class);
    if (custom == null) {
      // go for the external basic-environment adapter that we provide
      custom = OCLUtil.getAdapter(env, BasicEnvironment.class);
    }

    return custom.getValue(option);
  }
  /**
   * Add an option to apply to the specified environment, adapting it as necessary to the {@link
   * Customizable} API.
   *
   * @param env an environment on which to set an option
   * @param option the option
   * @param value the option's value
   * @see Cusotmizable#setOption(Option, Object)
   */
  public static <T> void setOption(
      Environment<?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> env, Option<T> option, T value) {

    Customizable custom = OCLUtil.getAdapter(env, Customizable.class);
    if (custom == null) {
      // go for the external basic-environment adapter that we provide
      custom = OCLUtil.getAdapter(env, BasicEnvironment.class);
    }

    custom.setOption(option, value);
  }
  public <T> T getValue(Option<T> option) {
    @SuppressWarnings("unchecked")
    T result = (T) getOptions().get(option);

    if (result == null) {
      Customizable parent =
          (getParent() != null) ? OCLUtil.getAdapter(getParent(), Customizable.class) : null;

      result = (parent != null) ? parent.getValue(option) : option.getDefaultValue();
    }

    return result;
  }
  public Map<Option<?>, Object> getOptions() {
    Customizable parent =
        (getParent() != null) ? OCLUtil.getAdapter(getParent(), Customizable.class) : null;

    Map<Option<?>, Object> result =
        (parent != null)
            ? new java.util.HashMap<Option<?>, Object>(parent.getOptions())
            : new java.util.HashMap<Option<?>, Object>();

    result.putAll(basicGetOptions());

    return result;
  }
Exemple #5
0
 public Diagnostic getProblems() {
   return OCLUtil.getEvaluationProblems(delegate);
 }