public static ModeParameterList build (final ModeParameterListBuilder builder) {
        if (!builder.checkIntegrity()) return null;
        // everything is okay, so
        // - calculate block descriptor length
        int blockDescriptorLength;
        if (builder.logicalBlockDescriptors == null)
            blockDescriptorLength = 0;
        else {
            int singleLbdLength;
            if (builder.longLba)
                singleLbdLength = LongLogicalBlockDescriptor.SIZE;
            else
                singleLbdLength = ShortLogicalBlockDescriptor.SIZE;
            blockDescriptorLength = builder.logicalBlockDescriptors.length * singleLbdLength;
        }
        // - calculate mode data length
        int modeDataLength;
        // -- calculate contribution of the header without bytes of MODE DATA
        // LENGTH field
        if (builder.headerType == HeaderType.MODE_PARAMETER_HEADER_6)
            modeDataLength = ModeParameterHeader6.SIZE - ModeParameterHeader6.MODE_DATA_LENGTH_FIELD_SIZE;
        else
            modeDataLength = ModeParameterHeader10.SIZE - ModeParameterHeader10.MODE_DATA_LENGTH_FIELD_SIZE;
        // -- add length of logical block descriptors
        modeDataLength += blockDescriptorLength;
        // -- add length of mode pages
        if (builder.modePages != null) for (ModePage mp : builder.modePages)
            modeDataLength += mp.size();

        /*
         * It might be nice to check the values for overflow here, however this is not necessary, since the length of
         * all available/returned elements will always be less than 256.
         */

        ModeParameterHeader modeParameterHeader;
        if (builder.headerType == HeaderType.MODE_PARAMETER_HEADER_6)
            modeParameterHeader = new ModeParameterHeader6(modeDataLength, blockDescriptorLength);
        else
            modeParameterHeader = new ModeParameterHeader10(modeDataLength, blockDescriptorLength, builder.longLba);

        // create and return the ModeParameterList
        return new ModeParameterList(modeParameterHeader, builder.logicalBlockDescriptors, builder.modePages);
    }
public static ModeParameterList build ( final ModeParameterListBuilder builder ) { if ( ! builder . checkIntegrity ( ) ) return null ; int blockDescriptorLength ; if ( builder . logicalBlockDescriptors == null ) blockDescriptorLength = 0 ; else { int singleLbdLength ; if ( builder . longLba ) singleLbdLength = LongLogicalBlockDescriptor . SIZE ; else singleLbdLength = ShortLogicalBlockDescriptor . SIZE ; blockDescriptorLength = builder . logicalBlockDescriptors . length * singleLbdLength ; } int modeDataLength ; if ( builder . headerType == HeaderType . MODE_PARAMETER_HEADER_6 ) modeDataLength = ModeParameterHeader6 . SIZE - ModeParameterHeader6 . MODE_DATA_LENGTH_FIELD_SIZE ; else modeDataLength = ModeParameterHeader10 . SIZE - ModeParameterHeader10 . MODE_DATA_LENGTH_FIELD_SIZE ; modeDataLength += blockDescriptorLength ; if ( builder . modePages != null ) for ( ModePage mp : builder . modePages ) modeDataLength += mp . size ( ) ; ModeParameterHeader modeParameterHeader ; if ( builder . headerType == HeaderType . MODE_PARAMETER_HEADER_6 ) modeParameterHeader = new ModeParameterHeader6 ( modeDataLength , blockDescriptorLength ) ; else modeParameterHeader = new ModeParameterHeader10 ( modeDataLength , blockDescriptorLength , builder . longLba ) ; return new ModeParameterList ( modeParameterHeader , builder . logicalBlockDescriptors , builder . modePages ) ; }
Returns a new {@link ModeParameterList} instance based the variables of the <i>builder</i> object. If these
variables are mutually exclusive, then this method will return <code>null</code> instead.

@param builder contains all necessary information to create a {@link ModeParameterList} object
@return a new {@link ModeParameterList} or <code>null</code>