11/*
2- * Copyright (c) 2019 Neil C Smith
2+ * Copyright (c) 2021 Neil C Smith
33 * Copyright (c) 2008 Wayne Meissner
44 *
55 * This file is part of gstreamer-java.
2222 * Describes a GStreamer version.
2323 * <p>
2424 * Also upstream documentation at
25- * <a href="https://gstreamer.freedesktop.org/data/doc/ gstreamer/stable/gstreamer/html/gstreamer-GstVersion .html"
26- * >https://gstreamer.freedesktop.org/data/doc/ gstreamer/stable/gstreamer/html/gstreamer-GstVersion .html</a>
25+ * <a href="https://gstreamer.freedesktop.org/documentation/ gstreamer/gst .html#gst_version "
26+ * >https://gstreamer.freedesktop.org/documentation/ gstreamer/gst .html#gst_version </a>
2727 * <p>
2828 */
2929public class Version {
@@ -37,9 +37,9 @@ public class Version {
3737 private final int major , minor , micro , nano ;
3838
3939 /**
40- * Constructor for creating a Version with micro and nano set to zero - most
41- * useful for requesting version in {@link Gst#init(org.freedesktop.gstreamer.Version)
42- * }
40+ * Constructor for creating a Version with micro and nano set to zero. For
41+ * requesting version in {@link Gst#init(org.freedesktop.gstreamer.Version)}
42+ * prefer using {@link #of(int, int)}.
4343 * <p>
4444 * <b>The library only supports major version 1</b>
4545 *
@@ -130,4 +130,28 @@ public boolean checkSatisfies(Version required) {
130130 || (major == required .major && minor == required .minor && micro >= required .micro );
131131 }
132132
133+ /**
134+ * Create a Version with specified major and minor version, and micro and
135+ * nano version set to zero. Useful for specifying a required version in
136+ * {@link Gst#init(org.freedesktop.gstreamer.Version)}.
137+ * <p>
138+ * <b>The library only supports major version 1</b>
139+ * <p>
140+ * Unlike the constructor this method will throw an exception if the version
141+ * is not greater or equal to {@link #BASELINE}, or the major version isn't
142+ * 1.
143+ *
144+ * @param major major version, currently must be 1
145+ * @param minor minor version, greater or equal to 8
146+ * @return requested version
147+ * @throws IllegalArgumentException if the requested version is invalid
148+ */
149+ public static Version of (int major , int minor ) {
150+ if (major == BASELINE .getMajor ()
151+ && minor >= BASELINE .getMinor ()) {
152+ return new Version (major , minor );
153+ }
154+ throw new IllegalArgumentException ("Invalid version" );
155+ }
156+
133157}
0 commit comments