changeset 10961:26175843fce0 11+18

8186187: Modify return type of public API StyleConverter.getEnumConverter() Reviewed-by: kcr, arapte Contributed-by: prem.balakrishnan@oracle.com
author pkbalakr
date Tue, 10 Jul 2018 12:39:21 +0530
parents 30186c02bc22
children 7994b7b41c83 ead24602fed6
files modules/javafx.graphics/src/main/java/javafx/css/StyleConverter.java modules/javafx.graphics/src/test/java/test/javafx/css/CssMetaDataTest.java
diffstat 2 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/javafx/css/StyleConverter.java	Mon Jul 09 15:58:26 2018 -0700
+++ b/modules/javafx.graphics/src/main/java/javafx/css/StyleConverter.java	Tue Jul 10 12:39:21 2018 +0530
@@ -153,7 +153,7 @@
      * of an {@code Enum} to an {@code Enum}
      * @see Enum#valueOf(java.lang.Class, java.lang.String)
      */
-    public static <E extends Enum<E>> StyleConverter<String, ? extends Enum<?>> getEnumConverter(Class<E> enumClass) {
+    public static <E extends Enum<E>> StyleConverter<String, E> getEnumConverter(Class<E> enumClass) {
         // TODO: reuse EnumConverter instances
         EnumConverter<E> converter;
         converter = new EnumConverter<>(enumClass);
--- a/modules/javafx.graphics/src/test/java/test/javafx/css/CssMetaDataTest.java	Mon Jul 09 15:58:26 2018 -0700
+++ b/modules/javafx.graphics/src/test/java/test/javafx/css/CssMetaDataTest.java	Tue Jul 10 12:39:21 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,7 @@
 import javafx.scene.Group;
 import javafx.scene.Node;
 import javafx.scene.Scene;
+import javafx.scene.layout.Pane;
 import javafx.scene.paint.Color;
 import javafx.scene.shape.Rectangle;
 import javafx.scene.text.Font;
@@ -82,6 +83,12 @@
 
 import static org.junit.Assert.*;
 
+enum TestEnum {
+    LEFT,
+    CENTER,
+    RIGHT,
+    JUSTIFY
+}
 
 public class CssMetaDataTest {
 
@@ -1288,4 +1295,20 @@
 
     }
 
+    @Test
+    public void testStyleConverterReturnType() {
+        final CssMetaData<Pane, TestEnum> TEST_ENUM =
+                new CssMetaData<Pane, TestEnum>("-test-enum", StyleConverter.getEnumConverter(TestEnum.class), TestEnum.LEFT, false) {
+                    @Override
+                    public boolean isSettable(Pane styleable) {
+                        return false;
+                    }
+
+                    @Override
+                    public StyleableProperty<TestEnum> getStyleableProperty(Pane styleable) {
+                        return null;
+                    }
+                };
+    }
+
 }