Package org.jboss.jandex

Examples of org.jboss.jandex.AnnotationInstance


           String accessType,
           Map<DotName, List<AnnotationInstance>> annotations,
           EntityBindingContext context) {
    super( name, attributeType, accessType, annotations, context );

    AnnotationInstance versionAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.VERSION );
    isVersioned = versionAnnotation != null;

    if ( isId() ) {
      // an id must be unique and cannot be nullable
      getColumnValues().setUnique( true );
View Full Code Here


    sb.append( "{name=" ).append( getName() );
    return sb.toString();
  }

  private void checkBasicAnnotation() {
    AnnotationInstance basicAnnotation = JandexHelper.getSingleAnnotation( annotations(), JPADotNames.BASIC );
    if ( basicAnnotation != null ) {
      FetchType fetchType = FetchType.LAZY;
      AnnotationValue fetchValue = basicAnnotation.value( "fetch" );
      if ( fetchValue != null ) {
        fetchType = Enum.valueOf( FetchType.class, fetchValue.asEnum() );
      }
      this.isLazy = fetchType == FetchType.LAZY;

      AnnotationValue optionalValue = basicAnnotation.value( "optional" );
      if ( optionalValue != null ) {
        this.isOptional = optionalValue.asBoolean();
      }
    }
  }
View Full Code Here

    }
  }

  // TODO - there is more todo for updatable and insertable. Checking the @Generated annotation is only one part (HF)
  private void checkGeneratedAnnotation() {
    AnnotationInstance generatedAnnotation = JandexHelper.getSingleAnnotation(
        annotations(),
        HibernateDotNames.GENERATED
    );
    if ( generatedAnnotation != null ) {
      this.isInsertable = false;

      AnnotationValue generationTimeValue = generatedAnnotation.value();
      if ( generationTimeValue != null ) {
        GenerationTime genTime = Enum.valueOf( GenerationTime.class, generationTimeValue.asEnum() );
        if ( GenerationTime.ALWAYS.equals( genTime ) ) {
          this.isUpdatable = false;
          this.propertyGeneration = PropertyGeneration.parse( genTime.toString().toLowerCase() );
View Full Code Here

  private List<AnnotationInstance> getAllColumnTransformerAnnotations() {
    List<AnnotationInstance> allColumnTransformerAnnotations = new ArrayList<AnnotationInstance>();

    // not quite sure about the usefulness of @ColumnTransformers (HF)
    AnnotationInstance columnTransformersAnnotations = JandexHelper.getSingleAnnotation(
        annotations(),
        HibernateDotNames.COLUMN_TRANSFORMERS
    );
    if ( columnTransformersAnnotations != null ) {
      AnnotationInstance[] annotationInstances = allColumnTransformerAnnotations.get( 0 ).value().asNestedArray();
      allColumnTransformerAnnotations.addAll( Arrays.asList( annotationInstances ) );
    }

    AnnotationInstance columnTransformerAnnotation = JandexHelper.getSingleAnnotation(
        annotations(),
        HibernateDotNames.COLUMN_TRANSFORMER
    );
    if ( columnTransformerAnnotation != null ) {
      allColumnTransformerAnnotations.add( columnTransformerAnnotation );
View Full Code Here

    return readWrite;
  }

  private String parseCheckAnnotation() {
    String checkCondition = null;
    AnnotationInstance checkAnnotation = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.CHECK );
    if ( checkAnnotation != null ) {
      checkCondition = checkAnnotation.value( "constraints" ).toString();
    }
    return checkCondition;
  }
View Full Code Here

    return checkCondition;
  }

  private IdGenerator checkGeneratedValueAnnotation() {
    IdGenerator generator = null;
    AnnotationInstance generatedValueAnnotation = JandexHelper.getSingleAnnotation(
        annotations(),
        JPADotNames.GENERATED_VALUE
    );
    if ( generatedValueAnnotation != null ) {
      String name = JandexHelper.getValue( generatedValueAnnotation, "generator", String.class );
View Full Code Here

    boolean hasOwnTable = definesItsOwnTable();
    this.explicitEntityName = determineExplicitEntityName();
    this.constraintSources = new HashSet<ConstraintSource>();

    if ( hasOwnTable ) {
      AnnotationInstance tableAnnotation = JandexHelper.getSingleAnnotation(
          getClassInfo(),
          JPADotNames.TABLE
      );
      this.primaryTableSource = createTableSource( tableAnnotation );
    }
View Full Code Here

  public List<JpaCallbackClass> getJpaCallbacks() {
    return jpaCallbacks;
  }

  private String determineExplicitEntityName() {
    final AnnotationInstance jpaEntityAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.ENTITY
    );
    return JandexHelper.getValue( jpaEntityAnnotation, "name", String.class );
  }
View Full Code Here

  private void processDiscriminator() {
    if ( !InheritanceType.SINGLE_TABLE.equals( inheritanceType ) ) {
      return;
    }

    final AnnotationInstance discriminatorValueAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.DISCRIMINATOR_VALUE
    );
    if ( discriminatorValueAnnotation != null ) {
      this.discriminatorMatchValue = discriminatorValueAnnotation.value().asString();
    }

    final AnnotationInstance discriminatorColumnAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), JPADotNames.DISCRIMINATOR_COLUMN
    );

    final AnnotationInstance discriminatorFormulaAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(),
        HibernateDotNames.DISCRIMINATOR_FORMULA
    );


    Class<?> type = String.class; // string is the discriminator default
    if ( discriminatorFormulaAnnotation != null ) {
      String expression = JandexHelper.getValue( discriminatorFormulaAnnotation, "value", String.class );
      discriminatorFormula = new FormulaValue( getPrimaryTableSource().getExplicitTableName(), expression );
    }
    discriminatorColumnValues = new ColumnValues( null ); //(stliu) give null here, will populate values below
    discriminatorColumnValues.setNullable( false ); // discriminator column cannot be null
    if ( discriminatorColumnAnnotation != null ) {

      DiscriminatorType discriminatorType = Enum.valueOf(
          DiscriminatorType.class, discriminatorColumnAnnotation.value( "discriminatorType" ).asEnum()
      );
      switch ( discriminatorType ) {
        case STRING: {
          type = String.class;
          break;
        }
        case CHAR: {
          type = Character.class;
          break;
        }
        case INTEGER: {
          type = Integer.class;
          break;
        }
        default: {
          throw new AnnotationException( "Unsupported discriminator type: " + discriminatorType );
        }
      }

      discriminatorColumnValues.setName(
          JandexHelper.getValue(
              discriminatorColumnAnnotation,
              "name",
              String.class
          )
      );
      discriminatorColumnValues.setLength(
          JandexHelper.getValue(
              discriminatorColumnAnnotation,
              "length",
              Integer.class
          )
      );
      discriminatorColumnValues.setColumnDefinition(
          JandexHelper.getValue(
              discriminatorColumnAnnotation,
              "columnDefinition",
              String.class
          )
      );
    }
    discriminatorType = type;

    AnnotationInstance discriminatorOptionsAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.DISCRIMINATOR_OPTIONS
    );
    if ( discriminatorOptionsAnnotation != null ) {
      isDiscriminatorForced = discriminatorOptionsAnnotation.value( "force" ).asBoolean();
      isDiscriminatorIncludedInSql = discriminatorOptionsAnnotation.value( "insert" ).asBoolean();
    }
    else {
      isDiscriminatorForced = false;
      isDiscriminatorIncludedInSql = true;
    }
View Full Code Here

      isDiscriminatorIncludedInSql = true;
    }
  }

  private void processHibernateEntitySpecificAnnotations() {
    final AnnotationInstance hibernateEntityAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.ENTITY
    );

    // see HHH-6400
    PolymorphismType polymorphism = PolymorphismType.IMPLICIT;
    if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "polymorphism" ) != null ) {
      polymorphism = PolymorphismType.valueOf( hibernateEntityAnnotation.value( "polymorphism" ).asEnum() );
    }
    isExplicitPolymorphism = polymorphism == PolymorphismType.EXPLICIT;

    // see HHH-6401
    OptimisticLockType optimisticLockType = OptimisticLockType.VERSION;
    if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "optimisticLock" ) != null ) {
      optimisticLockType = OptimisticLockType.valueOf(
          hibernateEntityAnnotation.value( "optimisticLock" )
              .asEnum()
      );
    }
    optimisticLockStyle = OptimisticLockStyle.valueOf( optimisticLockType.name() );

    final AnnotationInstance hibernateImmutableAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.IMMUTABLE
    );
    isMutable = hibernateImmutableAnnotation == null
        && hibernateEntityAnnotation != null
        && hibernateEntityAnnotation.value( "mutable" ) != null
        && hibernateEntityAnnotation.value( "mutable" ).asBoolean();


    final AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.WHERE
    );
    whereClause = whereAnnotation != null && whereAnnotation.value( "clause" ) != null ?
        whereAnnotation.value( "clause" ).asString() : null;

    final AnnotationInstance rowIdAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.ROW_ID
    );
    rowId = rowIdAnnotation != null && rowIdAnnotation.value() != null
        ? rowIdAnnotation.value().asString() : null;

    caching = determineCachingSettings();

    // see HHH-6397
    isDynamicInsert =
        hibernateEntityAnnotation != null
            && hibernateEntityAnnotation.value( "dynamicInsert" ) != null
            && hibernateEntityAnnotation.value( "dynamicInsert" ).asBoolean();

    // see HHH-6398
    isDynamicUpdate =
        hibernateEntityAnnotation != null
            && hibernateEntityAnnotation.value( "dynamicUpdate" ) != null
            && hibernateEntityAnnotation.value( "dynamicUpdate" ).asBoolean();


    // see HHH-6399
    isSelectBeforeUpdate =
        hibernateEntityAnnotation != null
            && hibernateEntityAnnotation.value( "selectBeforeUpdate" ) != null
            && hibernateEntityAnnotation.value( "selectBeforeUpdate" ).asBoolean();

    // Custom persister
    final String entityPersisterClass;
    final AnnotationInstance persisterAnnotation = JandexHelper.getSingleAnnotation(
        getClassInfo(), HibernateDotNames.PERSISTER
    );
    if ( persisterAnnotation == null || persisterAnnotation.value( "impl" ) == null ) {
      if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "persister" ) != null ) {
        entityPersisterClass = hibernateEntityAnnotation.value( "persister" ).asString();
      }
      else {
        entityPersisterClass = null;
      }
    }
    else {
      if ( hibernateEntityAnnotation != null && hibernateEntityAnnotation.value( "persister" ) != null ) {
        // todo : error?
      }
      entityPersisterClass = persisterAnnotation.value( "impl" ).asString();
    }
    this.customPersister = entityPersisterClass;
  }
View Full Code Here

TOP

Related Classes of org.jboss.jandex.AnnotationInstance

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.