Ejemplo n.º 1
0
  public ModelNode getAdress() {
    ModelNode baseAddress = new ModelNode();
    baseAddress.setEmptyList();

    if (profileSelection.getName() != null) baseAddress.add("profile", profileSelection.getName());

    return baseAddress;
  }
Ejemplo n.º 2
0
  /** a more lenient way to update values by type */
  public static void setValue(ModelNode target, ModelType type, Object propValue) {

    if (type.equals(ModelType.STRING)) {
      target.set((String) propValue);
    } else if (type.equals(ModelType.INT)) {
      target.set((Integer) propValue);
    } else if (type.equals(ModelType.DOUBLE)) {
      target.set((Double) propValue);
    } else if (type.equals(ModelType.LONG)) {
      // in some cases the server returns the wrong model type for numeric values
      // i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
      try {
        target.set((Long) propValue);
      } catch (Throwable e) { // ClassCastException
        target.set(Integer.valueOf((Integer) propValue));
      }
    } else if (type.equals(ModelType.BIG_DECIMAL)) {
      // in some cases the server returns the wrong model type for numeric values
      // i.e the description affords a ModelType.LONG, but a ModelType.INTEGER is returned
      try {
        target.set((BigDecimal) propValue);
      } catch (Throwable e) { // ClassCastException
        target.set(Double.valueOf((Double) propValue));
      }
    } else if (type.equals(ModelType.BOOLEAN)) {
      target.set((Boolean) propValue);
    } else if (type.equals(ModelType.LIST)) {
      target.setEmptyList();
      List list = (List) propValue;

      for (Object item : list) target.add(String.valueOf(item));
    } else {
      Log.warn("Type conversionnot supported for " + type);
      target.setEmptyObject();
    }
  }