You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/10/23 18:06:02 UTC

svn commit: r1813049 - /pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java

Author: rwhitcomb
Date: Mon Oct 23 18:06:02 2017
New Revision: 1813049

URL: http://svn.apache.org/viewvc?rev=1813049&view=rev
Log:
PIVOT-999: Add another default method for an oft-used operation on Dictionary:
"getFont" which does the casting to a Font object.

Modified:
    pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java

Modified: pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java?rev=1813049&r1=1813048&r2=1813049&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/Dictionary.java Mon Oct 23 18:06:02 2017
@@ -17,6 +17,7 @@
 package org.apache.pivot.collections;
 
 import java.awt.Color;
+import java.awt.Font;
 import java.io.Serializable;
 
 import org.apache.pivot.util.Utils;
@@ -202,4 +203,20 @@ public interface Dictionary<K, V> {
         }
     }
 
+    /**
+     * Using the other methods in this interface, retrieve a {@link Font} value
+     * from this dictionary; returning <tt>null</tt> if the key does not exist.
+     *
+     * @param key The key for the (supposed) <tt>Font</tt>
+     * value to retrieve.
+     * @return The font value, or <tt>null</tt> if the key is not present.
+     */
+    default Font getFont(K key) {
+        if (containsKey(key)) {
+            return (Font)get(key);
+        } else {
+            return (Font)null;
+        }
+    }
+
 }