code: public static AttrValUnion set(final int tangoType, final Object value) throws DevFailed {
          final AttributeDataType discriminator = AttributeTangoType.getTypeFromTango(tangoType).getAttributeDataType();
          final AttrValUnion union = new AttrValUnion();
          Object array = null;
          if (value.getClass().isArray()) {
              // convert to array of primitives if necessary
              array = org.tango.utils.ArrayUtils.toPrimitiveArray(value);
          } else {
              // put in an array before inserting for scalars
              array = Array.newInstance(AttributeTangoType.getTypeFromTango(tangoType).getType(), 1);
              try {
                  Array.set(array, 0, value);
              } catch (final IllegalArgumentException e) {
                  throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName()
                          + " is not of the good type");
              }
          }
          try {
              final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator),
                      PARAM_MAP.get(discriminator));
              method.invoke(union, array);
          } catch (final IllegalArgumentException e) {
              throw DevFailedUtils.newDevFailed(ExceptionMessages.ATTR_OPT_PROP, value.getClass().getCanonicalName()
                      + " is not of the good type");
          } catch (final IllegalAccessException e) {
              throw DevFailedUtils.newDevFailed(e);
          } catch (final InvocationTargetException e) {
              throw DevFailedUtils.newDevFailed(e.getCause());
          } catch (final SecurityException e) {
              throw DevFailedUtils.newDevFailed(e);
          } catch (final NoSuchMethodException e) {
              throw DevFailedUtils.newDevFailed(e);
          }
          return union;
      }
docs: Set a value into an AttrValUnion
  
  @param tangoType
  @param value
  @return The union
  @throws DevFailed