1 /** 2 * Copyright (c) 2008-2011, http://www.snakeyaml.org 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.yaml.snakeyaml.generics; 18 19 import java.beans.IntrospectionException; 20 import java.beans.Introspector; 21 import java.beans.PropertyDescriptor; 22 23 /** 24 * @see http://bugs.sun.com/view_bug.do?bug_id=6528714 25 */ 26 public class GenericsBugDetector { 27 /** 28 * Check whether the proper class Nest for Bird's property 'home' is 29 * recognized. 30 */ 31 public static boolean isProperIntrospection() throws IntrospectionException { 32 for (PropertyDescriptor property : Introspector.getBeanInfo(Bird.class) 33 .getPropertyDescriptors()) { 34 if (property.getName().equals("home")) { 35 return property.getPropertyType() == Nest.class; 36 } 37 } 38 throw new RuntimeException("Bird must contain 'home' property."); 39 } 40 }