public final class Conditional extends Object implements Writable
ConditionalAtRuleBlock
.Conditionals
Constructor and Description |
---|
Conditional(String condition,
boolean isLogicalNegation)
Creates a new
Conditional instance, with the given name and optional negation. |
Modifier and Type | Method and Description |
---|---|
String |
condition()
Gets the name of the condition.
|
boolean |
isLogicalNegation()
Returns true if the logical negation operator is present for this condition.
|
boolean |
isWritable()
Returns whether this unit should actually be written.
|
boolean |
matches(ConditionalsConfig config)
Checks whether this conditional is true based on the true conditions in the given ConditionalsConfig instance.
|
void |
write(StyleWriter writer,
StyleAppendable appendable)
Outputs this
Writable 's string representation. |
public Conditional(String condition, boolean isLogicalNegation)
Conditional
instance, with the given name and optional negation.condition
- The name of the condition, e.g., "ie7".isLogicalNegation
- Specify true if the logical negation operator is present, e.g., "!ie7".public String condition()
public boolean isLogicalNegation()
public boolean matches(ConditionalsConfig config)
If the given config contains a string condition matching this one, this method will return true, otherwise false. If isLogicalNegation()
is true then this return value is reversed.
config
- The config containing the set of true conditions.public boolean isWritable()
Writable
Usually this should just return true, however some units that are detachable or otherwise potentially invalid should first check their state and respond appropriately.
isWritable
in interface Writable
public void write(StyleWriter writer, StyleAppendable appendable) throws IOException
Writable
Writable
's string representation.
Important notes for implementation:
Do not use the StyleWriter
in an attempt to write direct content (Strings, chars, etc...). Use the StyleAppendable
.
The StyleWriter
should be used to make decisions based on writer settings (e.g., compressed vs. verbose output
mode), as well as for writing inner or child Writable
s. Do not call the this method method directly on inner
or child Writable
s! That would bypass any overrides that are set on the StyleWriter
. Use StyleWriter.writeInner(Writable, StyleAppendable)
instead.
write
in interface Writable
writer
- Writer to use for output settings and for writing inner Writable
s.appendable
- Append direct content to this StyleAppendable
.IOException
- If an I/O error occurs.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.