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.runtime;
  27 
  28 import java.lang.reflect.Type;
  29 import java.util.Collection;
  30 
  31 import com.sun.xml.internal.bind.v2.model.core.PropertyInfo;
  32 import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor;
  33 
  34 /**
  35  * {@link PropertyInfo} that exposes more information.
  36  *
  37  * @author Kohsuke Kawaguchi (kk@kohsuke.org)
  38  */
  39 public interface RuntimePropertyInfo extends PropertyInfo<Type,Class> {
  40 
  41     /** {@inheritDoc} */
  42     Collection<? extends RuntimeTypeInfo> ref();
  43 
  44 
  45     /**
  46      * Gets the {@link Accessor} for this property.
  47      *
  48      * <p>
  49      * Even for a multi-value property, this method returns an accessor
  50      * to that property. IOW, the accessor works against the raw type.
  51      *
  52      * <p>
  53      * This methods returns unoptimized accessor (because optimization
  54      * accessors are often combined into bigger pieces, and optimization
  55      * generally works better if you can look at a bigger piece, as opposed
  56      * to individually optimize a smaller components)
  57      *
  58      * @return
  59      *      never null.
  60      *
  61      * @see Accessor#optimize()
  62      */
  63     Accessor getAccessor();
  64 
  65     /**
  66      * Returns true if this property has an element-only content. False otherwise.
  67      */
  68     public boolean elementOnlyContent();
  69 
  70     /**
  71      * Gets the "raw" type of the field.
  72      *
  73      * The raw type is the actual signature of the property.
  74      * For example, if the field is the primitive int, this will be the primitive int.
  75      * If the field is Object, this will be Object.
  76      * If the property is the collection and typed as {@code Collection<Integer>},
  77      * this method returns {@code Collection<Integer>}.
  78      *
  79      * @return always non-null.
  80      */
  81     Type getRawType();
  82 
  83     /**
  84      * Gets the type of the individual item.
  85      *
  86      * The individual type is the signature of the property used to store individual
  87      * values. For a non-collection field, this is the same as {@link #getRawType()}.
  88      * For acollection property, this is the type used to store individual value.
  89      * So if {@link #getRawType()} is {@code Collection<Integer>}, this method will
  90      * return {@link Integer}.
  91      *
  92      * @return always non-null.
  93      */
  94     Type getIndividualType();
  95 }