Interface Constraint<T>

Type Parameters:
T - The type associated with this specific constraint for validation purposes.
All Known Subinterfaces:
BoolConstraint, DoubleConstraint, IntConstraint, StringConstraint
All Known Implementing Classes:
IconStringConstraints

public interface Constraint<T>
Represents a constraint applied to an object, which serves as a property. This may be any type of object, but must be validated by the class utilizing the constraint.
Since:
1.0.0.0
Author:
creatorfromhell
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    asString(T value)
    Used to convert a specified value associated with this type to a string.
    convert(String value)
    Used to convert the provided input into the specified object.
    The default value for this constraint.
    The identifier of the constraint.
    boolean
    Used to validate that the provided input is of the valid type.
  • Method Details

    • identifier

      String identifier()
      The identifier of the constraint.
      Returns:
      The constraint identifier.
    • defaultValue

      T defaultValue()
      The default value for this constraint.
      Returns:
      The default value for this constraint.
    • convert

      T convert(String value)
      Used to convert the provided input into the specified object.
      Parameters:
      value - The string to convert into the object.
      Returns:
      An optional containing the converted value, or an empty optional if the provided input can't be converted into the specified object.
    • validate

      boolean validate(String value)
      Used to validate that the provided input is of the valid type.
      Parameters:
      value - The input to validate.
      Returns:
      True if the input is of the type associated with this constraint, otherwise false.
    • asString

      default String asString(T value)
      Used to convert a specified value associated with this type to a string.
      Parameters:
      value - The value to convert.
      Returns:
      The String representation of the value provided.