public static Object get(final AttrValUnion union, final AttrDataFormat format) throws DevFailed {
        Object result = null;
        if (union != null) {
            final AttributeDataType discriminator = union.discriminator();
            if (discriminator.value() == AttributeDataType._ATT_NO_DATA) {
                throw DevFailedUtils.newDevFailed("there is not data");
            }
            try {
                final Method method = union.getClass().getMethod(METHOD_MAP.get(discriminator));
                result = method.invoke(union);
            } catch (final IllegalArgumentException e) {
                throw DevFailedUtils.newDevFailed(e);
            } 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);
            }
            if (format.equals(AttrDataFormat.SCALAR) && !discriminator.equals(AttributeDataType.DEVICE_STATE)) {
                // for scalar except state, get only first value
                result = Array.get(result, 0);
            }
        }
        return result;
    }
public static Object get ( final AttrValUnion union , final AttrDataFormat format ) throws DevFailed { Object result = null ; if ( union != null ) { final AttributeDataType discriminator = union . discriminator ( ) ; if ( discriminator . value ( ) == AttributeDataType . _ATT_NO_DATA ) { throw DevFailedUtils . newDevFailed ( "there is not data" ) ; } try { final Method method = union . getClass ( ) . getMethod ( METHOD_MAP . get ( discriminator ) ) ; result = method . invoke ( union ) ; } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } 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 ) ; } if ( format . equals ( AttrDataFormat . SCALAR ) && ! discriminator . equals ( AttributeDataType . DEVICE_STATE ) ) { result = Array . get ( result , 0 ) ; } } return result ; }
Get value from an AttrValUnion

@param union
@param format
@return The value
@throws DevFailed