Module technology.sola.engine
Record Class ConditionalStyle<Style extends BaseStyles>
java.lang.Object
java.lang.Record
technology.sola.engine.graphics.gui.style.ConditionalStyle<Style>
- Type Parameters:
Style
- the style type- Record Components:
condition
- the condition for when the style should be appliedstyle
- the style instance
@NullMarked
public record ConditionalStyle<Style extends BaseStyles>(Function<GuiElement<Style extends BaseStyles,?>,Boolean> condition, Style extends BaseStyles style)
extends Record
ConditionalStyle holds a
BaseStyles
instance and a condition for when it should be applied.-
Constructor Summary
ConstructorsConstructorDescriptionConditionalStyle
(Function<GuiElement<Style, ?>, Boolean> condition, Style style) Creates an instance of aConditionalStyle
record class. -
Method Summary
Modifier and TypeMethodDescriptionstatic <Style extends BaseStyles>
ConditionalStyle<Style>active
(Style style) Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is active.static <Style extends BaseStyles>
ConditionalStyle<Style>always
(Style style) Creates a ConditionalStyle instance for a style that will always be applied.Returns the value of thecondition
record component.static <Style extends BaseStyles>
ConditionalStyle<Style>disabled
(Style style) Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is disabled.final boolean
Indicates whether some other object is "equal to" this one.static <Style extends BaseStyles>
ConditionalStyle<Style>focus
(Style style) Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is focussed.final int
hashCode()
Returns a hash code value for this object.static <Style extends BaseStyles>
ConditionalStyle<Style>hover
(Style style) Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is hovered.boolean
boolean
style()
Returns the value of thestyle
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
always
Creates a ConditionalStyle instance for a style that will always be applied.- Type Parameters:
Style
- the style type- Parameters:
style
- the style to apply- Returns:
- a ConditionalStyle instance
-
active
Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is active.- Type Parameters:
Style
- the style type- Parameters:
style
- the style to apply- Returns:
- a ConditionalStyle instance
-
hover
Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is hovered.- Type Parameters:
Style
- the style type- Parameters:
style
- the style to apply- Returns:
- a ConditionalStyle instance
-
focus
Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is focussed.- Type Parameters:
Style
- the style type- Parameters:
style
- the style to apply- Returns:
- a ConditionalStyle instance
-
disabled
Creates a ConditionalStyle instance for a style that will be applied when theGuiElement
is disabled. This can only apply to elements that extendBaseInputGuiElement
.- Type Parameters:
Style
- the style type- Parameters:
style
- the style to apply- Returns:
- a ConditionalStyle instance
-
isActiveStyle
public boolean isActiveStyle()- Returns:
- true if the condition of this style is
GuiElement.isActive()
-
isHoverStyle
public boolean isHoverStyle()- Returns:
- true if the condition of this style is
GuiElement.isHovered()
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
condition
Returns the value of thecondition
record component.- Returns:
- the value of the
condition
record component
-
style
Returns the value of thestyle
record component.- Returns:
- the value of the
style
record component
-