001/*
002 * Copyright (c) 2023 Tada AB and other contributors, as listed below.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the The BSD 3-Clause License
006 * which accompanies this distribution, and is available at
007 * http://opensource.org/licenses/BSD-3-Clause
008 *
009 * Contributors:
010 *   Chapman Flack
011 */
012package org.postgresql.pljava.example.annotation;
013
014import org.postgresql.pljava.annotation.Function;
015
016/**
017 * Illustrates PL/Java functions on an interface instead of a class.
018 *<p>
019 * The SQL/JRT standard has always just said "class", but there is no technical
020 * obstacle to permitting a PL/Java function to be a static interface method, so
021 * that earlier restriction has been relaxed.
022 */
023public interface OnInterface
024{
025    /**
026     * Returns the answer.
027     */
028    @Function(schema = "javatest")
029    static int answer()
030    {
031        return 42;
032    }
033
034    interface A
035    {
036        /**
037         * Again the answer.
038         */
039        @Function(schema = "javatest")
040        static int nestedAnswer()
041        {
042            return 42;
043        }
044    }
045
046    class B
047    {
048        /**
049         * Still the answer.
050         */
051        @Function(schema = "javatest")
052        public static int nestedClassAnswer()
053        {
054            return 42;
055        }
056
057        public static class C
058        {
059            /**
060             * That answer again.
061             */
062            @Function(schema = "javatest")
063            public static int moreNestedAnswer()
064            {
065                return 42;
066            }
067        }
068    }
069}