public static final class PrinterCapabilitiesInfo.Builder extends Object
PrinterCapabilitiesInfo
. This class is
responsible to enforce that all required attributes have at least one
default value. In other words, this class creates only well-formed PrinterCapabilitiesInfo
s.
Look at the individual methods for a reference whether a property is required or if it is optional.
Constructor and Description |
---|
Builder(PrinterId printerId)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
PrinterCapabilitiesInfo.Builder |
addMediaSize(PrintAttributes.MediaSize mediaSize,
boolean isDefault)
Adds a supported media size.
|
PrinterCapabilitiesInfo.Builder |
addResolution(PrintAttributes.Resolution resolution,
boolean isDefault)
Adds a supported resolution.
|
PrinterCapabilitiesInfo |
build()
Crates a new
PrinterCapabilitiesInfo enforcing that all
required properties have been specified. |
PrinterCapabilitiesInfo.Builder |
setColorModes(int colorModes,
int defaultColorMode)
Sets the color modes.
|
PrinterCapabilitiesInfo.Builder |
setDuplexModes(int duplexModes,
int defaultDuplexMode)
Sets the duplex modes.
|
PrinterCapabilitiesInfo.Builder |
setMinMargins(PrintAttributes.Margins margins)
Sets the minimal margins.
|
public Builder(PrinterId printerId)
printerId
- The printer id. Cannot be null
.IllegalArgumentException
- If the printer id is null
.public PrinterCapabilitiesInfo.Builder addMediaSize(PrintAttributes.MediaSize mediaSize, boolean isDefault)
Required: Yes
mediaSize
- A media size.isDefault
- Whether this is the default.IllegalArgumentException
- If set as default and there
is already a default.PrintAttributes.MediaSize
public PrinterCapabilitiesInfo.Builder addResolution(PrintAttributes.Resolution resolution, boolean isDefault)
Required: Yes
resolution
- A resolution.isDefault
- Whether this is the default.IllegalArgumentException
- If set as default and there
is already a default.PrintAttributes.Resolution
public PrinterCapabilitiesInfo.Builder setMinMargins(PrintAttributes.Margins margins)
Required: Yes
margins
- The margins.IllegalArgumentException
- If margins are null
.PrintAttributes.Margins
public PrinterCapabilitiesInfo.Builder setColorModes(int colorModes, int defaultColorMode)
Required: Yes
colorModes
- The color mode bit mask.defaultColorMode
- The default color mode.Note: On platform version 19 (Kitkat) specifying only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler crash. Hence, you should declare either both color modes or PrintAttributes#COLOR_MODE_COLOR.
IllegalArgumentException
- If color modes contains an invalid
mode bit or if the default color mode is invalid.PrintAttributes.COLOR_MODE_COLOR
,
PrintAttributes.COLOR_MODE_MONOCHROME
public PrinterCapabilitiesInfo.Builder setDuplexModes(int duplexModes, int defaultDuplexMode)
Required: No
duplexModes
- The duplex mode bit mask.defaultDuplexMode
- The default duplex mode.IllegalArgumentException
- If duplex modes contains an invalid
mode bit or if the default duplex mode is invalid.PrintAttributes.DUPLEX_MODE_NONE
,
PrintAttributes.DUPLEX_MODE_LONG_EDGE
,
PrintAttributes.DUPLEX_MODE_SHORT_EDGE
public PrinterCapabilitiesInfo build()
PrinterCapabilitiesInfo
enforcing that all
required properties have been specified. See individual methods
in this class for reference about required attributes.
Note: If you do not add supported duplex modes,
PrintAttributes.DUPLEX_MODE_NONE
will set
as the only supported mode and also as the default duplex mode.
PrinterCapabilitiesInfo
.IllegalStateException
- If a required attribute was not specified.