Package java.lang.annotation

Examples of java.lang.annotation.Annotation


  private void getEmbeddedId(List<Annotation> annotationList, XMLContext.Default defaults) {
    for ( Element element : elementsForProperty ) {
      if ( "embedded-id".equals( element.getName() ) ) {
        if ( isProcessingId( defaults ) ) {
          Annotation annotation = getAttributeOverrides( element, defaults, false );
          addIfNotNull( annotationList, annotation );
          annotation = getAssociationOverrides( element, defaults, false );
          addIfNotNull( annotationList, annotation );
          AnnotationDescriptor ad = new AnnotationDescriptor( EmbeddedId.class );
          annotationList.add( AnnotationFactory.create( ad ) );
          getAccessType( annotationList, element );
        }
      }
    }
    if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
      Annotation annotation = getJavaAnnotation( EmbeddedId.class );
      if ( annotation != null ) {
        annotationList.add( annotation );
        annotation = getJavaAnnotation( Column.class );
        addIfNotNull( annotationList, annotation );
        annotation = getJavaAnnotation( Columns.class );
View Full Code Here


  private void getId(List<Annotation> annotationList, XMLContext.Default defaults) {
    for ( Element element : elementsForProperty ) {
      if ( "id".equals( element.getName() ) ) {
        boolean processId = isProcessingId( defaults );
        if ( processId ) {
          Annotation annotation = buildColumns( element );
          addIfNotNull( annotationList, annotation );
          annotation = buildGeneratedValue( element );
          addIfNotNull( annotationList, annotation );
          getTemporal( annotationList, element );
          //FIXME: fix the priority of xml over java for generator names
          annotation = getTableGenerator( element, defaults );
          addIfNotNull( annotationList, annotation );
          annotation = getSequenceGenerator( element, defaults );
          addIfNotNull( annotationList, annotation );
          AnnotationDescriptor id = new AnnotationDescriptor( Id.class );
          annotationList.add( AnnotationFactory.create( id ) );
          getAccessType( annotationList, element );
        }
      }
    }
    if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) {
      Annotation annotation = getJavaAnnotation( Id.class );
      if ( annotation != null ) {
        annotationList.add( annotation );
        annotation = getJavaAnnotation( Column.class );
        addIfNotNull( annotationList, annotation );
        annotation = getJavaAnnotation( Columns.class );
View Full Code Here

          builder.in(LazySingletonScope.get());
      }
    }
   
    private boolean hasScopeAnnotation(Class<?> clazz) {
      Annotation scopeAnnotation = null;
      for (Annotation annot : clazz.getAnnotations()) {
        if (annot.annotationType().isAnnotationPresent(ScopeAnnotation.class)) {
          Preconditions.checkState(scopeAnnotation == null, "Multiple scopes not allowed");
          scopeAnnotation = annot;
        }
View Full Code Here

   @Override
   public void proceed()
   {
      if (pos < handlers.size()) {
         AnnotationHandler<Annotation> handler = handlers.get(pos++);
         Annotation annotation = element.getAnnotation(handler.handles());
         Assert.notNull(annotation, "Could not find annotation [" + handler.handles().getName() + "] on: " + element);
         handler.process(context, annotation, this);
      }

   }
View Full Code Here

  @Marker
  public void testMapBinderMatching() throws Exception {
    Method m = MapBinderTest.class.getDeclaredMethod("testMapBinderMatching");
    assertNotNull(m);
    final Annotation marker = m.getAnnotation(Marker.class);
    Injector injector = Guice.createInjector(new AbstractModule() {
      @Override public void configure() {
        MapBinder<Integer, Integer> mb1 =
          MapBinder.newMapBinder(binder(), Integer.class, Integer.class, Marker.class);
        MapBinder<Integer, Integer> mb2 =
View Full Code Here

    return ProviderMethod.create(key, method, delegate, ImmutableSet.copyOf(dependencies),
        parameterProviders, scopeAnnotation, skipFastClassGeneration);
  }

  <T> Key<T> getKey(Errors errors, TypeLiteral<T> type, Member member, Annotation[] annotations) {
    Annotation bindingAnnotation = Annotations.findBindingAnnotation(errors, member, annotations);
    return bindingAnnotation == null ? Key.get(type) : Key.get(type, bindingAnnotation);
  }
View Full Code Here

  @Marker
  public void testMatchingMarkerAnnotations() throws Exception {
    Method m = OptionalBinderTest.class.getDeclaredMethod("testMatchingMarkerAnnotations");
    assertNotNull(m);
    final Annotation marker = m.getAnnotation(Marker.class);
    Injector injector = Guice.createInjector(new AbstractModule() {
      @Override public void configure() {
        OptionalBinder<Integer> mb1 =
            OptionalBinder.newOptionalBinder(binder(), Key.get(Integer.class, Marker.class));
        OptionalBinder<Integer> mb2 =
View Full Code Here

  @Marker
  public void testMultibinderMatching() throws Exception {
    Method m = MultibinderTest.class.getDeclaredMethod("testMultibinderMatching");
    assertNotNull(m);
    final Annotation marker = m.getAnnotation(Marker.class);
    Injector injector = Guice.createInjector(new AbstractModule() {
      @Override public void configure() {
        Multibinder<Integer> mb1 = Multibinder.newSetBinder(binder(), Integer.class, Marker.class);
        Multibinder<Integer> mb2 = Multibinder.newSetBinder(binder(), Integer.class, marker);
        mb1.addBinding().toInstance(1);
View Full Code Here

        injector.getInstance(Key.get(collectionOfJavaxProvidersOf(stringType)));
    assertEquals(expectedValues, collectValues(javaxProviders));
  }

  public void testMultibinderCanInjectCollectionOfProvidersWithAnnotation() {
    final Annotation ann = Names.named("foo");
    Module module = new AbstractModule() {
      protected void configure() {
        final Multibinder<String> multibinder =
            Multibinder.newSetBinder(binder(), String.class, ann);
        multibinder.addBinding().toProvider(Providers.of("A"));
View Full Code Here

        injector.getInstance(Key.get(collectionOfJavaxProvidersOf(stringType), ann));
    assertEquals(expectedValues, collectValues(javaxProviders));
  }

  public void testMultibindingProviderDependencies() {
    final Annotation setAnn = Names.named("foo");
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override protected void configure() {
          Multibinder<String> multibinder =
              Multibinder.newSetBinder(binder(), String.class, setAnn);
          multibinder.addBinding().toInstance("a");
View Full Code Here

TOP

Related Classes of java.lang.annotation.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.