public final class PropertyName extends AbstractSyntax implements Named
Declaration
.
This class is vendor prefix aware, which means that you can check if it isPrefixed()
, get the unprefixed()
,
or add/replace the prefix with prefix(Prefix)
method.
Use name()
to get the full property name, including the prefix if it is present.
The name of this property is immutable. If seeking to change the property name of a Declaration, see Declaration.propertyName(Property)
, Declaration.propertyName(String)
, and related methods (but this is generally
discouraged, as many plugins check and depend on the property name-- in some cases it might be better to replace the whole
declaration).
Modifier and Type | Method and Description |
---|---|
Optional<Property> |
asProperty()
Gets the exact matching
Property instance, if one exists (it may not exist if this is an unknown property or a
prefixed property). |
Optional<Property> |
asPropertyIgnorePrefix()
Gets matching
Property instance, if one exists (it may not exist if this is an unknown property.) This ignores the
prefix. |
PropertyName |
copy()
For implementations: do not copy comments or orphaned comments, instead be sure to call
AbstractSyntax.copiedFrom(Syntax) on the
new copy. |
boolean |
hasPrefix(Prefix prefix)
Gets whether this
PropertyName has the given Prefix . |
boolean |
hasStarHack()
Gets whether this
PropertyName includes an IE7 star hack (http://en.wikipedia.org/wiki/CSS_filter#Star_hack). |
boolean |
isPrefixed()
Gets whether this property name is prefixed.
|
boolean |
matches(Property property)
|
boolean |
matches(PropertyName other)
|
boolean |
matches(String name)
Gets whether this
PropertyName has a name() that equals the given string. |
boolean |
matchesIgnorePrefix(Property property)
Same as
matches(Property) , except this ignores the prefix. |
boolean |
matchesIgnorePrefix(PropertyName other)
Same as
matches(PropertyName) , except this ignores the prefix. |
boolean |
matchesIgnorePrefix(String name)
Same as
matches(String) , except this ignores the prefix of this property. |
String |
name()
Gets the full property name, including the prefix if present.
|
static PropertyName |
of(int line,
int column,
String name)
Creates a new
PropertyName from with the given String name. |
static PropertyName |
of(Property property)
Creates a new
PropertyName instance from the given Property . |
static PropertyName |
of(String name)
Creates a new
PropertyName instance using the given string. |
Optional<Prefix> |
prefix()
Gets the prefix, if present.
|
PropertyName |
prefix(Prefix prefix)
Sets the prefix for this property name.
|
PropertyName |
removePrefix()
Removes the current prefix from this property name.
|
PropertyName |
starHack(boolean starHack)
Sets if this
PropertyName includes an IE7 star hack (http://en.wikipedia.org/wiki/CSS_filter#Star_hack). |
String |
unprefixed()
Gets the unprefixed property name.
|
void |
write(StyleWriter writer,
StyleAppendable appendable)
Outputs this
Writable 's string representation. |
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copiedFrom, equals, hasAnnotation, hasAnnotation, hashCode, hasSourcePosition, id, isWritable, line, orphanedComments, orphanedComments, orphanedComments, propagateBroadcast, shouldBreakBroadcast, status, status, toString, toString, writesOwnComments, writesOwnOrphanedComments
public boolean hasStarHack()
PropertyName
includes an IE7 star hack (http://en.wikipedia.org/wiki/CSS_filter#Star_hack).PropertyName
includes the IE7 star hack.public PropertyName starHack(boolean starHack)
PropertyName
includes an IE7 star hack (http://en.wikipedia.org/wiki/CSS_filter#Star_hack).starHack
- True if this property name includes the star hackpublic String name()
public String unprefixed()
public boolean isPrefixed()
public boolean hasPrefix(Prefix prefix)
PropertyName
has the given Prefix
.prefix
- Match against this prefix.PropertyName
has the given Prefix
.public Optional<Prefix> prefix()
Optional
if not present.public PropertyName prefix(Prefix prefix)
prefix
- The Prefix
.public PropertyName removePrefix()
public Optional<Property> asProperty()
Property
instance, if one exists (it may not exist if this is an unknown property or a
prefixed property).Property
, or an empty Optional
if this PropertyName
is prefixed or it's unknown.public Optional<Property> asPropertyIgnorePrefix()
Property
instance, if one exists (it may not exist if this is an unknown property.) This ignores the
prefix.Property
, or an empty Optional
if this PropertyName
is unknown.public boolean matches(String name)
PropertyName
has a name()
that equals the given string.name
- Match against this property name.PropertyName
has a name that equals the given string, including the prefix if present.public boolean matches(Property property)
PropertyName
has a name()
that equals the given Property
. If this PropertyName
is prefixed then this will always return false.property
- Match against this property.PropertyName
has a name that equals the given Property
.public boolean matches(PropertyName other)
other
- Match against this property name (including the prefix).public boolean matchesIgnorePrefix(Property property)
matches(Property)
, except this ignores the prefix.property
- Match against this property.PropertyName
has a name that equals the given Property
, ignoring the prefix.public boolean matchesIgnorePrefix(PropertyName other)
matches(PropertyName)
, except this ignores the prefix.other
- Match against this property name.PropertyName
s have equal unprefixed()
s.public boolean matchesIgnorePrefix(String name)
matches(String)
, except this ignores the prefix of this property.name
- The property name.PropertyName
has a name that equals the given string, ignoring the prefix of this property.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.public PropertyName copy()
AbstractSyntax
AbstractSyntax.copiedFrom(Syntax)
on the
new copy.copy
in interface Syntax
copy
in class AbstractSyntax
public static PropertyName of(String name)
PropertyName
instance using the given string. Prefer to use of(Property)
instead.
Please note that the property name will be automatically lower-cased.
name
- The property name.PropertyName
instance.public static PropertyName of(int line, int column, String name)
PropertyName
from with the given String name. Prefer to use of(Property)
instead.
Please note that the property name will be automatically lower-cased.
name
- The name of the property.line
- The line number of the start of the property name.column
- The column number of the start of the property.PropertyName
instance.public static PropertyName of(Property property)
PropertyName
instance from the given Property
.property
- The Property
name.PropertyName
instance.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.