Class AdaptiveProperty<T,P extends Property<T>>
java.lang.Object
dev.prozilla.pine.common.property.adaptive.AdaptiveProperty<T,P>
- All Implemented Interfaces:
Animatable,Property<T>,Functor<T>
- Direct Known Subclasses:
AdaptiveFloatProperty,AdaptiveIntProperty,AdaptiveObjectProperty
public abstract class AdaptiveProperty<T,P extends Property<T>>
extends Object
implements Property<T>, Animatable
Base class for an optimized property that can either have a fixed value or be dynamically changed by a
Property.
This class provides a more efficient alternative to using Property exclusively,
allowing for fixed values when dynamic behavior is unnecessary.
- If a
Propertyis provided, the property updates dynamically. - If an
AnimatedObjectPropertyis provided, the property will be updated each frame by the animation. - If neither is provided, the property remains fixed.
Certain implementations store fixed values as primitives to optimize performance and avoid unnecessary (un)boxing.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveProperty(P property) Creates a new property with a dynamic value ifvariablePropertyis notnull, or a fixed value. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether this property has an animated value.booleanChecks whether this property has a dynamic value.voidRestarts the animation of this property, if it is animated.voidupdateAnimation(float deltaTime) Updates the animation of this property, if it is animated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.prozilla.pine.common.property.Property
getValue, getValueOr, hasValue, hasValueProperty, isNotNull, isNotNullProperty, isNull, map, replaceNull, requireValue, snapshot, toStringProperty
-
Field Details
-
property
-
animatedProperty
-
-
Constructor Details
-
AdaptiveProperty
Creates a new property with a dynamic value ifvariablePropertyis notnull, or a fixed value.- Parameters:
property- Variable property that determines the value of this property
-
-
Method Details
-
restartAnimation
public void restartAnimation()Restarts the animation of this property, if it is animated.- Specified by:
restartAnimationin interfaceAnimatable
-
updateAnimation
public void updateAnimation(float deltaTime) Updates the animation of this property, if it is animated.- Specified by:
updateAnimationin interfaceAnimatable- Parameters:
deltaTime- Time between this frame and the last one, in seconds.
-
isDynamic
public boolean isDynamic()Checks whether this property has a dynamic value. -
isAnimated
public boolean isAnimated()Checks whether this property has an animated value.
-