< prev index next >

src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JAnnotationArrayMember.java

Print this page


   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


 235         values.add(annotationValue);
 236         return this;
 237     }
 238 
 239     /**
 240      * Adds a new annotation to the array.
 241      */
 242     public JAnnotationUse annotate(Class<? extends Annotation> clazz){
 243         return annotate(owner.ref(clazz));
 244     }
 245 
 246     /**
 247      * Adds a new annotation to the array.
 248      */
 249     public JAnnotationUse annotate(JClass clazz){
 250         JAnnotationUse a = new JAnnotationUse(clazz);
 251         values.add(a);
 252         return a;
 253     }
 254 





 255     public <W extends JAnnotationWriter> W annotate2(Class<W> clazz) {
 256         return TypedAnnotationWriter.create(clazz,this);
 257     }
 258 
 259     /**
 260      * {@link JAnnotatable#annotations()}
 261      */
 262     @SuppressWarnings("unchecked")
 263         public Collection<JAnnotationUse> annotations() {
 264         // this invocation is invalid if the caller isn't adding annotations into an array
 265         // so this potentially type-unsafe conversion would be justified.
 266         return Collections.<JAnnotationUse>unmodifiableList((List)values);
 267     }
 268 
 269     /**
 270      * Adds an annotation member to this annotation  array
 271      * This can be used for e.g @XmlCollection(values= @XmlCollectionItem(type=Foo.class))
 272      * @param value
 273      *        Adds a annotation  to the array member
 274      * @return


   1 /*
   2  * Copyright (c) 1997, 2014, 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


 235         values.add(annotationValue);
 236         return this;
 237     }
 238 
 239     /**
 240      * Adds a new annotation to the array.
 241      */
 242     public JAnnotationUse annotate(Class<? extends Annotation> clazz){
 243         return annotate(owner.ref(clazz));
 244     }
 245 
 246     /**
 247      * Adds a new annotation to the array.
 248      */
 249     public JAnnotationUse annotate(JClass clazz){
 250         JAnnotationUse a = new JAnnotationUse(clazz);
 251         values.add(a);
 252         return a;
 253     }
 254 
 255 
 256     public boolean removeAnnotation(JAnnotationUse annotation) {
 257         return this.values.remove(annotation);
 258     }
 259 
 260     public <W extends JAnnotationWriter> W annotate2(Class<W> clazz) {
 261         return TypedAnnotationWriter.create(clazz,this);
 262     }
 263 
 264     /**
 265      * {@link JAnnotatable#annotations()}
 266      */
 267     @SuppressWarnings("unchecked")
 268         public Collection<JAnnotationUse> annotations() {
 269         // this invocation is invalid if the caller isn't adding annotations into an array
 270         // so this potentially type-unsafe conversion would be justified.
 271         return Collections.<JAnnotationUse>unmodifiableList((List)values);
 272     }
 273 
 274     /**
 275      * Adds an annotation member to this annotation  array
 276      * This can be used for e.g @XmlCollection(values= @XmlCollectionItem(type=Foo.class))
 277      * @param value
 278      *        Adds a annotation  to the array member
 279      * @return


< prev index next >