Enum Breakpoint

  • All Implemented Interfaces:
    Serializable, Comparable<Breakpoint>

    public enum Breakpoint
    extends Enum<Breakpoint>
    The Breakpoint class represents different breakpoints for responsive design.

    Breakpoints are used to define the varying screen widths and heights at which a website or application layout should change.

    The class is implemented as an enum with a fixed set of predefined breakpoints:

    • default_ - The default breakpoint, used when no other breakpoint matches the given width or height.
    • sm - The small breakpoint.
    • md - The medium breakpoint.
    • lg - The large breakpoint.
    • xl - The extra large breakpoint.
    • _2xl - The 2x extra large breakpoint.

    The class provides utility methods to retrieve the appropriate breakpoint based on a given width or height, using the methods breakpoint(int width) and verticalBreakpoint(int height).

    Each instance of the Breakpoint class has the following information:

    • value - The name or identifier of the breakpoint.
    • widthValue - The width value of the breakpoint in pixels.
    • widthCss - The width value of the breakpoint in CSS units.
    • heightValue - The height value of the breakpoint in pixels.
    • heightCss - The height value of the breakpoint in CSS units.
    • Field Detail

      • value

        public final String value
      • widthValue

        public final int widthValue
      • widthCss

        public final String widthCss
      • heightValue

        public final int heightValue
      • heightCss

        public final String heightCss
    • Method Detail

      • values

        public static Breakpoint[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Breakpoint c : Breakpoint.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Breakpoint valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • breakpoint

        public static Breakpoint breakpoint​(int width)
        Determines the breakpoint for a given width value.
        Parameters:
        width - the width value
        Returns:
        the breakpoint corresponding to the given width value or default_ if no width matches.
      • verticalBreakpoint

        public static Breakpoint verticalBreakpoint​(int height)
        Determines the breakpoint based on the given height value.
        Parameters:
        height - the height value to determine the breakpoint for
        Returns:
        the Breakpoint corresponding to the given height value or default_ if no height matches.