Package org.jboss.jandex

Examples of org.jboss.jandex.AnnotationInstance


      return InheritanceType.NO_INHERITANCE;
    }

    // if we have more than one entity class the default is SINGLE_TABLE
    InheritanceType inheritanceType = InheritanceType.SINGLE_TABLE;
    AnnotationInstance inheritanceAnnotation = JandexHelper.getSingleAnnotation(
        rootClassInfo, JPADotNames.INHERITANCE
    );
    if ( inheritanceAnnotation != null ) {
      String enumName = inheritanceAnnotation.value( "strategy" ).asEnum();
      javax.persistence.InheritanceType jpaInheritanceType = Enum.valueOf(
          javax.persistence.InheritanceType.class, enumName
      );
      inheritanceType = InheritanceType.get( jpaInheritanceType );
    }
View Full Code Here


  private AccessType determineClassAccessType(AccessType defaultAccessType) {
    // default to the hierarchy access type to start with
    AccessType accessType = defaultAccessType;

    AnnotationInstance accessAnnotation = JandexHelper.getSingleAnnotation( classInfo, JPADotNames.ACCESS );
    if ( accessAnnotation != null && accessAnnotation.target().getClass().equals( ClassInfo.class ) ) {
      accessType = JandexHelper.getEnumValue( accessAnnotation, "value", AccessType.class );
    }

    return accessType;
  }
View Full Code Here

      }
      case EMBEDDED_ID: {
        throw new NotYetImplementedException( "Embedded ids must still be implemented." );
      }
      case EMBEDDED: {
        AnnotationInstance targetAnnotation = JandexHelper.getSingleAnnotation(
            getClassInfo(),
            HibernateDotNames.TARGET
        );
        if ( targetAnnotation != null ) {
          attributeType = localBindingContext.locateClassByName(
View Full Code Here

   */
  private AttributeNature determineAttributeNature(Map<DotName, List<AnnotationInstance>> annotations) {
    EnumMap<AttributeNature, AnnotationInstance> discoveredAttributeTypes =
        new EnumMap<AttributeNature, AnnotationInstance>( AttributeNature.class );

    AnnotationInstance oneToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_ONE );
    if ( oneToOne != null ) {
      discoveredAttributeTypes.put( AttributeNature.ONE_TO_ONE, oneToOne );
    }

    AnnotationInstance oneToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_MANY );
    if ( oneToMany != null ) {
      discoveredAttributeTypes.put( AttributeNature.ONE_TO_MANY, oneToMany );
    }

    AnnotationInstance manyToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_ONE );
    if ( manyToOne != null ) {
      discoveredAttributeTypes.put( AttributeNature.MANY_TO_ONE, manyToOne );
    }

    AnnotationInstance manyToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_MANY );
    if ( manyToMany != null ) {
      discoveredAttributeTypes.put( AttributeNature.MANY_TO_MANY, manyToMany );
    }

    AnnotationInstance embedded = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED );
    if ( embedded != null ) {
      discoveredAttributeTypes.put( AttributeNature.EMBEDDED, embedded );
    }

    AnnotationInstance embeddedId = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED_ID );
    if ( embeddedId != null ) {
      discoveredAttributeTypes.put( AttributeNature.EMBEDDED_ID, embeddedId );
    }

    AnnotationInstance elementCollection = JandexHelper.getSingleAnnotation(
        annotations,
        JPADotNames.ELEMENT_COLLECTION
    );
    if ( elementCollection != null ) {
      discoveredAttributeTypes.put( AttributeNature.ELEMENT_COLLECTION, elementCollection );
View Full Code Here

  }

  private Map<String, AttributeOverride> findAttributeOverrides() {
    Map<String, AttributeOverride> attributeOverrideList = new HashMap<String, AttributeOverride>();

    AnnotationInstance attributeOverrideAnnotation = JandexHelper.getSingleAnnotation(
        classInfo,
        JPADotNames.ATTRIBUTE_OVERRIDE
    );
    if ( attributeOverrideAnnotation != null ) {
      String prefix = createPathPrefix( attributeOverrideAnnotation.target() );
      AttributeOverride override = new AttributeOverride( prefix, attributeOverrideAnnotation );
      attributeOverrideList.put( override.getAttributePath(), override );
    }

    AnnotationInstance attributeOverridesAnnotation = JandexHelper.getSingleAnnotation(
        classInfo,
        JPADotNames.ATTRIBUTE_OVERRIDES
    );
    if ( attributeOverridesAnnotation != null ) {
      AnnotationInstance[] annotationInstances = attributeOverridesAnnotation.value().asNestedArray();
      for ( AnnotationInstance annotationInstance : annotationInstances ) {
        String prefix = createPathPrefix( attributeOverridesAnnotation.target() );
        AttributeOverride override = new AttributeOverride( prefix, annotationInstance );
        attributeOverrideList.put( override.getAttributePath(), override );
      }
    }
    return attributeOverrideList;
View Full Code Here

  }

  private List<AnnotationInstance> findAssociationOverrides() {
    List<AnnotationInstance> associationOverrideList = new ArrayList<AnnotationInstance>();

    AnnotationInstance associationOverrideAnnotation = JandexHelper.getSingleAnnotation(
        classInfo,
        JPADotNames.ASSOCIATION_OVERRIDE
    );
    if ( associationOverrideAnnotation != null ) {
      associationOverrideList.add( associationOverrideAnnotation );
    }

    AnnotationInstance associationOverridesAnnotation = JandexHelper.getSingleAnnotation(
        classInfo,
        JPADotNames.ASSOCIATION_OVERRIDES
    );
    if ( associationOverrideAnnotation != null ) {
      AnnotationInstance[] attributeOverride = associationOverridesAnnotation.value().asNestedArray();
      Collections.addAll( associationOverrideList, attributeOverride );
    }

    return associationOverrideList;
  }
View Full Code Here

    return associationOverrideList;
  }

  private String determineCustomTuplizer() {
    final AnnotationInstance tuplizersAnnotation = JandexHelper.getSingleAnnotation(
        classInfo, HibernateDotNames.TUPLIZERS
    );
    if ( tuplizersAnnotation == null ) {
      return null;
    }

    AnnotationInstance[] annotations = JandexHelper.getValue(
        tuplizersAnnotation,
        "value",
        AnnotationInstance[].class
    );

    AnnotationInstance pojoTuplizerAnnotation = null;
    for ( AnnotationInstance tuplizerAnnotation : annotations ) {
      if ( EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ) == EntityMode.POJO ) {
        pojoTuplizerAnnotation = tuplizerAnnotation;
        break;
      }
    }

    String customTuplizer = null;
    if ( pojoTuplizerAnnotation != null ) {
      customTuplizer = pojoTuplizerAnnotation.value( "impl" ).asString();
    }
    return customTuplizer;
  }
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

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.