Class HexColorValue
- java.lang.Object
-
- com.salesforce.omakase.ast.AbstractSyntax
-
- com.salesforce.omakase.ast.collection.AbstractGroupable<PropertyValue,PropertyValueMember>
-
- com.salesforce.omakase.ast.declaration.AbstractTerm
-
- com.salesforce.omakase.ast.declaration.HexColorValue
-
- All Implemented Interfaces:
Groupable<PropertyValue,PropertyValueMember>
,PropertyValueMember
,Term
,Syntax
,Broadcastable
,Writable
public final class HexColorValue extends AbstractTerm
A hex color value (e.g., "fffeee"). The value is always converted to lower-case.- See Also:
HexColorValue
-
-
Constructor Summary
Constructors Constructor Description HexColorValue(int line, int column, String color)
Constructs a new instance of aHexColorValue
.HexColorValue(String color)
Constructs a new instance of aHexColorValue
(used for dynamically createdSyntax
units).HexColorValue(String color, boolean lowerCaseAndNoHex)
Constructs a new instance of aHexColorValue
(used for dynamically createdSyntax
units).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
color()
Gets the color value (does not include the #).HexColorValue
color(String color)
Sets the value of the color (will be converted to lower-case).HexColorValue
copy()
For implementations: do not copy comments or orphaned comments, instead be sure to callAbstractSyntax.copiedFrom(Syntax)
on the new copy.boolean
isShorthand()
Gets whether this hex color is shorthand (has a length of three).static HexColorValue
of(String color)
Creates a newHexColorValue
instance using the given color (do not include the #).String
textualValue()
Gets the color value (does not include the #).void
write(StyleWriter writer, StyleAppendable appendable)
Outputs thisWritable
's string representation.-
Methods inherited from class com.salesforce.omakase.ast.declaration.AbstractTerm
declaration, isTerm, self
-
Methods inherited from class com.salesforce.omakase.ast.collection.AbstractGroupable
append, destroy, group, group, isDestroyed, isFirst, isLast, isWritable, next, parent, prepend, previous, replaceWith, unlink
-
Methods inherited from class com.salesforce.omakase.ast.AbstractSyntax
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, copiedFrom, equals, hasAnnotation, hasAnnotation, hashCode, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, propagateBroadcast, shouldBreakBroadcast, status, status, toString, toString, writesOwnComments, writesOwnOrphanedComments
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.salesforce.omakase.broadcast.Broadcastable
propagateBroadcast, shouldBreakBroadcast, status, status
-
Methods inherited from interface com.salesforce.omakase.ast.collection.Groupable
append, destroy, group, group, isDestroyed, isFirst, isLast, next, parent, prepend, previous, replaceWith, unlink
-
Methods inherited from interface com.salesforce.omakase.ast.Syntax
annotate, annotateUnlessPresent, annotation, annotations, column, comment, comment, comments, comments, comments, hasAnnotation, hasAnnotation, hasSourcePosition, id, line, orphanedComments, orphanedComments, orphanedComments, toString, writesOwnComments, writesOwnOrphanedComments
-
Methods inherited from interface com.salesforce.omakase.writer.Writable
isWritable
-
-
-
-
Constructor Detail
-
HexColorValue
public HexColorValue(int line, int column, String color)
Constructs a new instance of aHexColorValue
.If dynamically creating a new instance then use
HexColorValue(String)
instead.- Parameters:
line
- The line number.column
- The column number.color
- The hex color (do not include the #). Automatically lower-cased.
-
HexColorValue
public HexColorValue(String color)
Constructs a new instance of aHexColorValue
(used for dynamically createdSyntax
units).- Parameters:
color
- The hex color (do not include the #).
-
HexColorValue
public HexColorValue(String color, boolean lowerCaseAndNoHex)
Constructs a new instance of aHexColorValue
(used for dynamically createdSyntax
units). Only use this when you already know the string is lower-cased and doesn't start with a '#'.- Parameters:
color
- The hex color (do not include the #).lowerCaseAndNoHex
- Specifies whether the string is already lower-cased and doesn't start with a '#'.
-
-
Method Detail
-
color
public HexColorValue color(String color)
Sets the value of the color (will be converted to lower-case).- Parameters:
color
- The hex color (do not include the #). Automatically lower-cased.- Returns:
- this, for chaining.
-
color
public String color()
Gets the color value (does not include the #).- Returns:
- The color value.
-
isShorthand
public boolean isShorthand()
Gets whether this hex color is shorthand (has a length of three).- Returns:
- True if the length of this color is 3.
-
textualValue
public String textualValue()
Gets the color value (does not include the #). Prefer to usecolor()
, which is identical to this method.- Returns:
- The color value.
-
write
public void write(StyleWriter writer, StyleAppendable appendable) throws IOException
Description copied from interface:Writable
Outputs thisWritable
's string representation.Important notes for implementation:
Do not use the
StyleWriter
in an attempt to write direct content (Strings, chars, etc...). Use theStyleAppendable
.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 childWritable
s. Do not call the this method method directly on inner or childWritable
s! That would bypass any overrides that are set on theStyleWriter
. UseStyleWriter.writeInner(Writable, StyleAppendable)
instead.- Parameters:
writer
- Writer to use for output settings and for writing innerWritable
s.appendable
- Append direct content to thisStyleAppendable
.- Throws:
IOException
- If an I/O error occurs.
-
copy
public HexColorValue copy()
Description copied from class:AbstractSyntax
For implementations: do not copy comments or orphaned comments, instead be sure to callAbstractSyntax.copiedFrom(Syntax)
on the new copy.- Specified by:
copy
in interfacePropertyValueMember
- Specified by:
copy
in interfaceSyntax
- Specified by:
copy
in interfaceTerm
- Specified by:
copy
in classAbstractSyntax
- Returns:
- The new instance.
-
of
public static HexColorValue of(String color)
Creates a newHexColorValue
instance using the given color (do not include the #).Example:
HexColorValue.of("fffeee")
- Parameters:
color
- The color value. Automatically lower-cased.- Returns:
- The new
HexColorValue
instance.
-
-