1 /* 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.xml.internal.bind.v2.model.core; 27 28 import java.util.Map; 29 30 import javax.xml.namespace.QName; 31 32 /** 33 * Property that maps to the following schema fragment. 34 * 35 * <pre><xmp> 36 * <xs:complexType> 37 * <xs:sequence> 38 * <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> 39 * <xs:complexType> 40 * <xs:sequence> 41 * <xs:element name="key" type="XXXX"/> 42 * <xs:element name="value" type="YYYY"/> 43 * </xs:sequence> 44 * </xs:complexType> 45 * </xs:element> 46 * </xs:sequence> 47 * </xs:complexType> 48 * </xmp></pre> 49 * 50 * <p> 51 * This property is used to represent a default binding of a {@link Map} property. 52 * ({@link Map} properties with adapters will be represented by {@link ElementPropertyInfo}.) 53 * 54 * 55 * <h2>Design Thinking Led to This</h2> 56 * <p> 57 * I didn't like the idea of adding such a special-purpose {@link PropertyInfo} to a model. 58 * The alternative was to implicitly assume an adapter, and have internal representation of 59 * the Entry class ready. 60 * But the fact that the key type and the value type changes with the parameterization makes 61 * it very difficult to have such a class (especially inside Annotation Processing, where we can't even generate 62 * classes.) 63 * 64 * @author Kohsuke Kawaguchi 65 */ 66 public interface MapPropertyInfo<T,C> extends PropertyInfo<T,C> { 67 /** 68 * Gets the wrapper element name. 69 * 70 * @return 71 * always non-null. 72 */ 73 QName getXmlName(); 74 75 /** 76 * Returns true if this property is nillable 77 * (meaning the absence of the value is treated as nil='true') 78 * 79 * <p> 80 * This method is only used when this property is a collection. 81 */ 82 boolean isCollectionNillable(); 83 84 /** 85 * Type of the key of the map. K of {@code HashMap<K,V>} 86 * 87 * @return never null. 88 */ 89 NonElement<T,C> getKeyType(); 90 91 /** 92 * Type of the value of the map. V of {@code HashMap<K,V>} 93 * 94 * @return never null. 95 */ 96 NonElement<T,C> getValueType(); 97 98 // TODO 99 // Adapter<T,C> getKeyAdapter(); 100 // Adapter<T,C> getValueAdapter(); 101 }