public FormatOptions filter ( int allowedFlags , boolean allowWidth , boolean allowPrecision ) { if ( isDefault ( ) ) { return this ; } int newFlags = allowedFlags & flags ; int newWidth = allowWidth ? width : UNSET ; int newPrecision = allowPrecision ? precision : UNSET ; // Remember that we must never create a non-canonical default instance. if ( newFlags == 0 && newWidth == UNSET && newPrecision == UNSET ) { return DEFAULT ; } // This check would be faster if we encoded the entire state into a long value. It's also // entirely possible we should just allocate a new instance and be damned (especially as // having anything other than the default instance is rare). // TODO(dbeaumont): Measure performance and see about removing this code, almost certainly fine. if ( newFlags == flags && newWidth == width && newPrecision == precision ) { return this ; } return new FormatOptions ( newFlags , newWidth , newPrecision ) ; }
Returns a possibly new FormatOptions instance possibly containing a subset of the formatting information . This is useful if a backend implementation wishes to create formatting options that ignore some of the specified formatting information .