Author: rwhitcomb
Date: Fri Feb  2 23:44:33 2018
New Revision: 1823010

URL: http://svn.apache.org/viewvc?rev=1823010&view=rev
Log:
PIVOT-1027:  Introduce an @UnsupportedOperation annotation and apply it
(along with some Javadoc changes) to NumericSpinnerData, which has a number
of these unsupported methods.  This is basically a proof-of-concept for
this idea, which could be applied all over the place to methods that need
an implementation because of the interface or superclass from which they
are derived, but which are really not supported for various (good) reasons.
This annotation is primarily for documentation purposes, so it is not
retained at runtime.

Added:
    pivot/trunk/core/src/org/apache/pivot/annotations/
    pivot/trunk/core/src/org/apache/pivot/annotations/UnsupportedOperation.java
Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/content/NumericSpinnerData.java

Added: 
pivot/trunk/core/src/org/apache/pivot/annotations/UnsupportedOperation.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/annotations/UnsupportedOperation.java?rev=1823010&view=auto
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/annotations/UnsupportedOperation.java 
(added)
+++ pivot/trunk/core/src/org/apache/pivot/annotations/UnsupportedOperation.java 
Fri Feb  2 23:44:33 2018
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pivot.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * An annotation to explicitly mark a method that will always throw
+ * {@link UnsupportedOperationException} when called.
+ */
+@Retention(RetentionPolicy.SOURCE)
+@Target(ElementType.METHOD)
+@Documented
+public @interface UnsupportedOperation {
+
+     boolean value() default true;
+}

Modified: 
pivot/trunk/wtk/src/org/apache/pivot/wtk/content/NumericSpinnerData.java
URL: 
http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/NumericSpinnerData.java?rev=1823010&r1=1823009&r2=1823010&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/content/NumericSpinnerData.java 
(original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/content/NumericSpinnerData.java 
Fri Feb  2 23:44:33 2018
@@ -21,6 +21,7 @@ import java.util.ConcurrentModificationE
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import org.apache.pivot.annotations.UnsupportedOperation;
 import org.apache.pivot.collections.List;
 import org.apache.pivot.collections.ListListener;
 import org.apache.pivot.collections.Sequence;
@@ -145,26 +146,51 @@ public class NumericSpinnerData implemen
         this.increment = increment;
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public int add(Integer item) {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public void insert(Integer item, int index) {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public Integer update(int index, Integer item) {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public int remove(Integer item) {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public Sequence<Integer> remove(int index, int count) {
         throw new UnsupportedOperationException();
@@ -195,6 +221,11 @@ public class NumericSpinnerData implemen
         return index;
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public void clear() {
         throw new UnsupportedOperationException();
@@ -210,11 +241,20 @@ public class NumericSpinnerData implemen
         return ((upperBound - lowerBound) / increment) + 1;
     }
 
+    /**
+     * Not supported in this class.
+     * @return {@code null} always (comparators are not supported)
+     */
     @Override
     public Comparator<Integer> getComparator() {
         return null;
     }
 
+    /**
+     * Not supported in this class.
+     * @throws UnsupportedOperationException always.
+     */
+    @UnsupportedOperation
     @Override
     public void setComparator(Comparator<Integer> comparator) {
         throw new UnsupportedOperationException();


Reply via email to