Class Point

  • All Implemented Interfaces:
    SQLData

    @SQLAction(requires={"point mirror type","point assertHasValues"},
               install="SELECT javatest.assertHasValues(CAST(\'(1,2)\' AS point), 1, 2)")
    @MappedUDT(name="point",
               provides="point mirror type")
    public class Point
    extends Object
    implements SQLData
    Example of a "mirrored UDT": a user-defined type that exposes to Java the internal representation of an existing (but not SQL-standard) PostgreSQL type. Naturally, the author of this type has to know (from the PostgreSQL source) that a Point is stored as two float8s, x first and then y.
    • Constructor Detail

    • Method Detail

      • logAndReturn

        @Function(schema="javatest",
                  requires="point mirror type",
                  effects=IMMUTABLE,
                  onNullInput=RETURNS_NULL)
        public static Point logAndReturn​(Point pt)
        Return the same 'point' passed in, logging its contents at level INFO.
        Parameters:
        pt - any instance of the type this UDT mirrors
        Returns:
        the same instance passed in
      • assertHasValues

        @Function(schema="javatest",
                  requires="point mirror type",
                  provides="point assertHasValues",
                  effects=IMMUTABLE,
                  onNullInput=RETURNS_NULL)
        public static void assertHasValues​(Point pt,
                                           double x,
                                           double y)
                                    throws SQLException
        Assert a 'point' has given x and y values, to test that its representation in Java corresponds to what PostgreSQL sees.
        Parameters:
        pt - an instance of this UDT
        x - the x value it should have
        y - the y value it should have
        Throws:
        SQLException - if the values do not match