Package com.sun.codemodel

Examples of com.sun.codemodel.JAnnotationArrayMember


        {
            a.param( "valueColumnName", gen.getValueColumnName() );
        }
        if ( !gen.getUniqueConstraint().isEmpty() )
        {
            final JAnnotationArrayMember uclst = a.paramArray( "uniqueConstraints" );
            for ( UniqueConstraint uc : gen.getUniqueConstraint() )
            {
                final JAnnotationUse uca = uclst.annotate( javax.persistence.UniqueConstraint.class );
                final JAnnotationArrayMember colNames = uca.paramArray( "columnNames" );
                for ( String cn : uc.getColumnName() )
                {
                    colNames.param( cn );
                }
            }
        }
    }
View Full Code Here


            final JMethod getter = this.getGetter( c, e.getName() );
            getter.annotate( cm.ref( javax.persistence.Embedded.class ) );
            if ( !e.getAttributeOverride().isEmpty() )
            {
                final JAnnotationUse aolst = getter.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
                final JAnnotationArrayMember value = aolst.paramArray( "value" );
                for ( AttributeOverride o : e.getAttributeOverride() )
                {
                    final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AttributeOverride.class ) );
                    if ( o.getColumn() != null )
                    {
                        final JAnnotationUse ac = ao.param( "column", cm.ref( javax.persistence.Column.class ) );
                        this.annotate( ac, o.getColumn() );
                    }
                    if ( o.getName() != null )
                    {
                        ao.param( "name", o.getName() );
                    }
                }
            }
        }

        if ( a.getEmbeddedId() != null )
        {
            final JMethod getter = this.getGetter( c, a.getEmbeddedId().getName() );
            getter.annotate( cm.ref( javax.persistence.EmbeddedId.class ) );
            if ( !a.getEmbeddedId().getAttributeOverride().isEmpty() )
            {
                final JAnnotationUse aolst = getter.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
                final JAnnotationArrayMember value = aolst.paramArray( "value" );
                for ( AttributeOverride o : a.getEmbeddedId().getAttributeOverride() )
                {
                    final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AttributeOverride.class ) );
                    if ( o.getColumn() != null )
                    {
                        final JAnnotationUse ac = ao.param( "column", cm.ref( javax.persistence.Column.class ) );
                        this.annotate( ac, o.getColumn() );
                    }
                    if ( o.getName() != null )
                    {
                        ao.param( "name", o.getName() );
                    }
                }
            }
        }

        for ( Id i : a.getId() )
        {
            final JMethod getter = this.getGetter( c, i.getName() );
            getter.annotate( cm.ref( javax.persistence.Id.class ) );
            if ( i.getColumn() != null )
            {
                final JAnnotationUse column = getter.annotate( cm.ref( javax.persistence.Column.class ) );
                this.annotate( column, i.getColumn() );
            }
            if ( i.getGeneratedValue() != null )
            {
                final JAnnotationUse gv = getter.annotate( cm.ref( javax.persistence.GeneratedValue.class ) );
                if ( i.getGeneratedValue().getGenerator() != null )
                {
                    gv.param( "generator", i.getGeneratedValue().getGenerator() );
                }
                if ( i.getGeneratedValue().getStrategy() != null )
                {
                    gv.param( "strategy", javax.persistence.GenerationType.valueOf(
                        i.getGeneratedValue().getStrategy().value() ) );

                }
            }
            if ( i.getSequenceGenerator() != null )
            {
                final JAnnotationUse gen = getter.annotate( cm.ref( javax.persistence.SequenceGenerator.class ) );
                this.annotate( gen, i.getSequenceGenerator() );
            }
            if ( i.getTableGenerator() != null )
            {
                final JAnnotationUse gen = getter.annotate( cm.ref( javax.persistence.TableGenerator.class ) );
                this.annotate( gen, i.getTableGenerator() );
            }
            if ( i.getTemporal() != null )
            {
                final JAnnotationUse temp = getter.annotate( cm.ref( javax.persistence.Temporal.class ) );
                temp.param( "value", javax.persistence.TemporalType.valueOf( i.getTemporal().value() ) );
            }
        }

        for ( ManyToMany m : a.getManyToMany() )
        {
            final JMethod getter = this.getGetter( c, m.getName() );
            final JAnnotationUse m2m = getter.annotate( cm.ref( javax.persistence.ManyToMany.class ) );

            if ( m.getCascade() != null )
            {
                this.annotate( m2m, m.getCascade() );
            }
            if ( m.getFetch() != null )
            {
                m2m.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
            }
            if ( m.getJoinTable() != null )
            {
                final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
                this.annotate( cm, jt, m.getJoinTable() );
            }
            if ( m.getMapKey() != null )
            {
                final JAnnotationUse mk = getter.annotate( cm.ref( javax.persistence.MapKey.class ) );
                mk.param( "name", m.getMapKey().getName() );
            }
            if ( m.getMappedBy() != null )
            {
                m2m.param( "mappedBy", m.getMappedBy() );
            }
            if ( m.getOrderBy() != null )
            {
                final JAnnotationUse ob = getter.annotate( cm.ref( javax.persistence.OrderBy.class ) );
                ob.param( "value", m.getOrderBy() );
            }
            if ( m.getTargetEntity() != null )
            {
                m2m.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
            }
        }

        for ( ManyToOne m : a.getManyToOne() )
        {
            final JMethod getter = this.getGetter( c, m.getName() );
            final JAnnotationUse m2o = getter.annotate( cm.ref( javax.persistence.ManyToOne.class ) );
            if ( m.getCascade() != null )
            {
                this.annotate( m2o, m.getCascade() );
            }
            if ( m.getFetch() != null )
            {
                m2o.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
            }
            if ( !m.getJoinColumn().isEmpty() )
            {
                for ( JoinColumn jc : m.getJoinColumn() )
                {
                    final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                    this.annotate( jca, jc );
                }
            }
            if ( m.getJoinTable() != null )
            {
                final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
                this.annotate( cm, jt, m.getJoinTable() );
            }
            if ( m.getTargetEntity() != null )
            {
                m2o.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
            }
            if ( m.isOptional() != null )
            {
                m2o.param( "optional", m.isOptional().booleanValue() );
            }
        }

        for ( OneToMany m : a.getOneToMany() )
        {
            final JMethod getter = this.getGetter( c, m.getName() );
            final JAnnotationUse o2m = getter.annotate( cm.ref( javax.persistence.OneToMany.class ) );

            if ( m.getCascade() != null )
            {
                this.annotate( o2m, m.getCascade() );
            }
            if ( m.getFetch() != null )
            {
                o2m.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
            }
            if ( !m.getJoinColumn().isEmpty() )
            {
                for ( JoinColumn jc : m.getJoinColumn() )
                {
                    final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                    this.annotate( jca, jc );
                }
            }
            if ( m.getJoinTable() != null )
            {
                final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
                this.annotate( cm, jt, m.getJoinTable() );
            }
            if ( m.getMapKey() != null )
            {
                final JAnnotationUse mk = getter.annotate( cm.ref( javax.persistence.MapKey.class ) );
                mk.param( "name", m.getMapKey().getName() );
            }
            if ( m.getMappedBy() != null )
            {
                o2m.param( "mappedBy", m.getMappedBy() );
            }
            if ( m.getOrderBy() != null )
            {
                final JAnnotationUse ob = getter.annotate( cm.ref( javax.persistence.OrderBy.class ) );
                ob.param( "value", m.getOrderBy() );
            }
            if ( m.getTargetEntity() != null )
            {
                o2m.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
            }
        }

        for ( OneToOne m : a.getOneToOne() )
        {
            final JMethod getter = this.getGetter( c, m.getName() );
            final JAnnotationUse o2o = getter.annotate( cm.ref( javax.persistence.OneToOne.class ) );
            if ( m.getCascade() != null )
            {
                this.annotate( o2o, m.getCascade() );
            }
            if ( m.isOptional() != null )
            {
                o2o.param( "optional", m.isOptional().booleanValue() );
            }
            if ( m.getFetch() != null )
            {
                o2o.param( "fetch", javax.persistence.FetchType.valueOf( m.getFetch().value() ) );
            }
            if ( !m.getJoinColumn().isEmpty() )
            {
                for ( JoinColumn jc : m.getJoinColumn() )
                {
                    final JAnnotationUse jca = getter.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                    this.annotate( jca, jc );
                }
            }
            if ( m.getJoinTable() != null )
            {
                final JAnnotationUse jt = getter.annotate( cm.ref( javax.persistence.JoinTable.class ) );
                this.annotate( cm, jt, m.getJoinTable() );
            }
            if ( m.getMappedBy() != null )
            {
                o2o.param( "mappedBy", m.getMappedBy() );
            }
            if ( !m.getPrimaryKeyJoinColumn().isEmpty() )
            {
                final JAnnotationUse pkjcs = getter.annotate( cm.ref( javax.persistence.PrimaryKeyJoinColumns.class ) );
                final JAnnotationArrayMember pkjc = pkjcs.paramArray( "value" );
                this.annotate( cm, pkjc, m.getPrimaryKeyJoinColumn() );
            }
            if ( m.getTargetEntity() != null )
            {
                o2o.param( "targetEntity", cm.ref( m.getTargetEntity() ) );
View Full Code Here

        }

        if ( !entity.getAssociationOverride().isEmpty() )
        {
            final JAnnotationUse aolst = c.implClass.annotate( cm.ref( javax.persistence.AssociationOverrides.class ) );
            final JAnnotationArrayMember value = aolst.paramArray( "value" );
            for ( AssociationOverride o : entity.getAssociationOverride() )
            {
                final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AssociationOverride.class ) );
                if ( o.getName() != null )
                {
                    ao.param( "name", o.getName() );
                }

                if ( !o.getJoinColumn().isEmpty() )
                {
                    final JAnnotationArrayMember joinColumns = ao.paramArray( "joinColumns" );
                    for ( JoinColumn jc : o.getJoinColumn() )
                    {
                        final JAnnotationUse jca = joinColumns.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                        this.annotate( jca, jc );
                    }
                }
            }
        }

        if ( !entity.getAttributeOverride().isEmpty() )
        {
            final JAnnotationUse aolst = c.implClass.annotate( cm.ref( javax.persistence.AttributeOverrides.class ) );
            final JAnnotationArrayMember value = aolst.paramArray( "value" );
            for ( AttributeOverride o : entity.getAttributeOverride() )
            {
                final JAnnotationUse ao = value.annotate( cm.ref( javax.persistence.AttributeOverride.class ) );
                if ( o.getColumn() != null )
                {
                    final JAnnotationUse ac = ao.param( "column", cm.ref( javax.persistence.Column.class ) );
                    this.annotate( ac, o.getColumn() );
                }
                if ( o.getName() != null )
                {
                    ao.param( "name", o.getName() );
                }
            }
        }

        if ( entity.getAttributes() != null )
        {
            this.annotate( cm, c, entity.getAttributes() );
        }

        if ( entity.getDiscriminatorColumn() != null )
        {
            final JAnnotationUse dc = c.implClass.annotate( cm.ref( javax.persistence.DiscriminatorColumn.class ) );
            if ( entity.getDiscriminatorColumn().getColumnDefinition() != null )
            {
                dc.param( "columnDefinition", entity.getDiscriminatorColumn().getColumnDefinition() );
            }
            if ( entity.getDiscriminatorColumn().getDiscriminatorType() != null )
            {
                dc.param( "discriminatorType", javax.persistence.DiscriminatorType.valueOf(
                    entity.getDiscriminatorColumn().getDiscriminatorType().value() ) );

            }
            if ( entity.getDiscriminatorColumn().getLength() != null )
            {
                dc.param( "length", entity.getDiscriminatorColumn().getLength().intValue() );
            }
            if ( entity.getDiscriminatorColumn().getName() != null )
            {
                dc.param( "name", entity.getDiscriminatorColumn().getName() );
            }
        }

        if ( entity.getDiscriminatorValue() != null )
        {
            final JAnnotationUse dv = c.implClass.annotate( cm.ref( javax.persistence.DiscriminatorValue.class ) );
            dv.param( "value", entity.getDiscriminatorValue() );
        }

        if ( entity.getEntityListeners() != null )
        {
            this.annotate( c, entity.getEntityListeners() );
        }

        if ( entity.getExcludeDefaultListeners() != null )
        {
            c.implClass.annotate( cm.ref( javax.persistence.ExcludeDefaultListeners.class ) );
        }
        if ( entity.getExcludeSuperclassListeners() != null )
        {
            c.implClass.annotate( cm.ref( javax.persistence.ExcludeSuperclassListeners.class ) );
        }
        if ( entity.getIdClass() != null )
        {
            this.annotate( c, entity.getIdClass() );
        }
        if ( entity.getInheritance() != null )
        {
            final JAnnotationUse ih = c.implClass.annotate( cm.ref( javax.persistence.Inheritance.class ) );
            ih.param( "strategy",
                      javax.persistence.InheritanceType.valueOf( entity.getInheritance().getStrategy().value() ) );

        }
        if ( !entity.getNamedNativeQuery().isEmpty() )
        {
            final JAnnotationUse nnqlst = c.implClass.annotate( cm.ref( javax.persistence.NamedNativeQueries.class ) );
            final JAnnotationArrayMember value = nnqlst.paramArray( "value" );
            for ( NamedNativeQuery q : entity.getNamedNativeQuery() )
            {
                final JAnnotationUse qa = value.annotate( cm.ref( javax.persistence.NamedNativeQuery.class ) );
                qa.param( "name", q.getName() );
                qa.param( "query", q.getQuery() );

                if ( q.getResultClass() != null )
                {
                    qa.param( "resultClass", cm.ref( q.getResultClass() ) );
                }
                if ( q.getResultSetMapping() != null )
                {
                    qa.param( "resultSetMapping", q.getResultSetMapping() );
                }
                if ( !q.getHint().isEmpty() )
                {
                    final JAnnotationArrayMember hints = qa.paramArray( "hints" );
                    for ( QueryHint hint : q.getHint() )
                    {
                        final JAnnotationUse qh = hints.annotate( javax.persistence.QueryHint.class );
                        qh.param( "name", hint.getName() );
                        qh.param( "value", hint.getValue() );
                    }
                }
            }
        }
        if ( !entity.getNamedQuery().isEmpty() )
        {
            final JAnnotationUse nqlst = c.implClass.annotate( cm.ref( javax.persistence.NamedQueries.class ) );
            final JAnnotationArrayMember value = nqlst.paramArray( "value" );
            for ( NamedQuery q : entity.getNamedQuery() )
            {
                final JAnnotationUse nq = value.annotate( cm.ref( javax.persistence.NamedQuery.class ) );
                nq.param( "name", q.getName() );
                nq.param( "query", q.getQuery() );

                if ( !q.getHint().isEmpty() )
                {
                    final JAnnotationArrayMember hints = nq.paramArray( "hints" );
                    for ( QueryHint hint : q.getHint() )
                    {
                        final JAnnotationUse qh = hints.annotate( javax.persistence.QueryHint.class );
                        qh.param( "name", hint.getName() );
                        qh.param( "value", hint.getValue() );
                    }
                }
            }
        }
        if ( entity.getPostLoad() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPostLoad().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PostLoad.class ) );
        }
        if ( entity.getPostPersist() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPostPersist().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PostPersist.class ) );
        }
        if ( entity.getPostRemove() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPostRemove().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PostRemove.class ) );
        }
        if ( entity.getPostUpdate() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPostUpdate().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PostUpdate.class ) );
        }
        if ( entity.getPrePersist() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPreUpdate().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PrePersist.class ) );
        }
        if ( entity.getPreRemove() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPreRemove().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PreRemove.class ) );
        }
        if ( entity.getPreUpdate() != null )
        {
            final JMethod m = this.getMethod( c, entity.getPreUpdate().getMethodName() );
            m.annotate( cm.ref( javax.persistence.PreUpdate.class ) );
        }
        if ( !entity.getPrimaryKeyJoinColumn().isEmpty() )
        {
            final JAnnotationUse pkjcs = c.implClass.annotate( cm.ref( javax.persistence.PrimaryKeyJoinColumns.class ) );
            final JAnnotationArrayMember pkjc = pkjcs.paramArray( "value" );
            this.annotate( cm, pkjc, entity.getPrimaryKeyJoinColumn() );
        }
        if ( !entity.getSecondaryTable().isEmpty() )
        {
            final JAnnotationUse stlst = c.implClass.annotate( cm.ref( javax.persistence.SecondaryTables.class ) );
            final JAnnotationArrayMember value = stlst.paramArray( "value" );
            for ( SecondaryTable t : entity.getSecondaryTable() )
            {
                final JAnnotationUse st = value.annotate( cm.ref( javax.persistence.SecondaryTable.class ) );
                if ( t.getCatalog() != null )
                {
                    st.param( "catalog", t.getCatalog() );
                }
                if ( t.getName() != null )
                {
                    st.param( "name", t.getName() );
                }
                if ( !t.getPrimaryKeyJoinColumn().isEmpty() )
                {
                    final JAnnotationArrayMember pkjc = st.paramArray( "pkJoinColumns" );
                    this.annotate( cm, pkjc, entity.getPrimaryKeyJoinColumn() );
                }
                if ( t.getSchema() != null )
                {
                    st.param( "schema", t.getSchema() );
                }
                if ( !t.getUniqueConstraint().isEmpty() )
                {
                    final JAnnotationArrayMember uca = st.paramArray( "uniqueConstraints" );
                    for ( UniqueConstraint uc : t.getUniqueConstraint() )
                    {
                        final JAnnotationUse u = uca.annotate( javax.persistence.UniqueConstraint.class );
                        final JAnnotationArrayMember colNames = u.paramArray( "columnNames" );
                        for ( String cn : uc.getColumnName() )
                        {
                            colNames.param( cn );
                        }
                    }
                }
            }
        }
        if ( entity.getSequenceGenerator() != null )
        {
            final JAnnotationUse sg = c.implClass.annotate( cm.ref( javax.persistence.SequenceGenerator.class ) );
            this.annotate( sg, entity.getSequenceGenerator() );
        }
        if ( !entity.getSqlResultSetMapping().isEmpty() )
        {
            final JAnnotationUse lst = c.implClass.annotate( cm.ref( javax.persistence.SqlResultSetMappings.class ) );
            final JAnnotationArrayMember value = lst.paramArray( "value" );
            for ( SqlResultSetMapping m : entity.getSqlResultSetMapping() )
            {
                final JAnnotationUse srsm = value.annotate( cm.ref( javax.persistence.SqlResultSetMapping.class ) );
                if ( !m.getColumnResult().isEmpty() )
                {
                    final JAnnotationArrayMember cols = srsm.paramArray( "columns" );
                    for ( ColumnResult cr : m.getColumnResult() )
                    {
                        final JAnnotationUse cra = cols.annotate( javax.persistence.ColumnResult.class );
                        cra.param( "name", cr.getName() );
                    }
                }
                if ( !m.getEntityResult().isEmpty() )
                {
                    final JAnnotationArrayMember entities = srsm.paramArray( "entities" );
                    for ( EntityResult er : m.getEntityResult() )
                    {
                        final JAnnotationUse era = entities.annotate( javax.persistence.EntityResult.class );
                        if ( er.getDiscriminatorColumn() != null )
                        {
                            era.param( "discriminatorColumn", er.getDiscriminatorColumn() );
                        }
                        if ( er.getEntityClass() != null )
                        {
                            era.param( "entityClass", cm.ref( er.getEntityClass() ) );
                        }
                        if ( !er.getFieldResult().isEmpty() )
                        {
                            final JAnnotationArrayMember fields = era.paramArray( "fields" );
                            for ( FieldResult fr : er.getFieldResult() )
                            {
                                final JAnnotationUse fra = fields.annotate( javax.persistence.FieldResult.class );
                                if ( fr.getColumn() != null )
                                {
                                    fra.param( "column", fr.getColumn() );
                                }
                                if ( fr.getName() != null )
                                {
                                    fra.param( "name", fr.getName() );
                                }
                            }
                        }
                    }
                }
                if ( m.getName() != null )
                {
                    srsm.param( "name", m.getName() );
                }
            }
        }
        if ( entity.getTable() != null )
        {
            final JAnnotationUse ta = c.implClass.annotate( cm.ref( javax.persistence.Table.class ) );
            if ( entity.getTable().getCatalog() != null )
            {
                ta.param( "catalog", entity.getTable().getCatalog() );
            }
            if ( entity.getTable().getName() != null )
            {
                ta.param( "name", entity.getTable().getName() );
            }
            if ( entity.getTable().getSchema() != null )
            {
                ta.param( "schema", entity.getTable().getSchema() );
            }
            if ( !entity.getTable().getUniqueConstraint().isEmpty() )
            {
                final JAnnotationArrayMember uclst = ta.paramArray( "uniqueConstraints" );
                for ( UniqueConstraint uc : entity.getTable().getUniqueConstraint() )
                {
                    final JAnnotationUse uca = uclst.annotate( javax.persistence.UniqueConstraint.class );
                    final JAnnotationArrayMember colNames = uca.paramArray( "columnNames" );
                    for ( String cn : uc.getColumnName() )
                    {
                        colNames.param( cn );
                    }
                }
            }
        }
        if ( entity.getTableGenerator() != null )
View Full Code Here

    private void annotate( final ClassOutline c, final EntityListeners l )
    {
        final JAnnotationUse lst =
            c.implClass.annotate( c.parent().getCodeModel().ref( javax.persistence.EntityListeners.class ) );

        final JAnnotationArrayMember value = lst.paramArray( "value" );
        for ( EntityListener el : l.getEntityListener() )
        {
            value.param( c.parent().getCodeModel().ref( el.getClazz() ) );
        }
    }
View Full Code Here

        {
            a.param( "schema", jt.getSchema() );
        }
        if ( !jt.getInverseJoinColumn().isEmpty() )
        {
            final JAnnotationArrayMember ijclst = a.paramArray( "inverseJoinColumns" );
            for ( JoinColumn jc : jt.getInverseJoinColumn() )
            {
                final JAnnotationUse ijc = ijclst.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                this.annotate( ijc, jc );
            }
        }
        if ( !jt.getJoinColumn().isEmpty() )
        {
            final JAnnotationArrayMember jclst = a.paramArray( "joinColumns" );
            for ( JoinColumn jc : jt.getJoinColumn() )
            {
                final JAnnotationUse jca = jclst.annotate( cm.ref( javax.persistence.JoinColumn.class ) );
                this.annotate( jca, jc );
            }
        }
        if ( !jt.getUniqueConstraint().isEmpty() )
        {
            final JAnnotationArrayMember uclst = a.paramArray( "uniqueConstraints" );
            for ( UniqueConstraint uc : jt.getUniqueConstraint() )
            {
                final JAnnotationUse uca = uclst.annotate( javax.persistence.UniqueConstraint.class );
                final JAnnotationArrayMember colNames = uca.paramArray( "columnNames" );
                for ( String cn : uc.getColumnName() )
                {
                    colNames.param( cn );
                }
            }
        }
    }
View Full Code Here

        }

        // explicit fault action
        if (o.getFaults() != null && o.getFaults().size() > 0) {
            Map<String, JClass> map = o.getFaults();
            JAnnotationArrayMember jam = null;

            for (Fault f : o.faults()) {
                if (f.getAction() == null)
                    continue;

                if (f.getAction().equals(""))
                    continue;

                if (actionAnn == null) {
                    actionAnn = jMethod.annotate(Action.class);
                }
                if (jam == null) {
                    jam = actionAnn.paramArray("fault");
                }
                final JAnnotationUse faAnn = jam.annotate(FaultAction.class);
                faAnn.param("className", map.get(f.getName()));
                faAnn.param("value", f.getAction());
            }
        }
    }
View Full Code Here

            originalImplField.name(fieldName);
            fieldPropertyInfo.setName(false, fieldName);

            // Correct the @XmlType class-level annotation:
            JAnnotationArrayMember propOrderValue = (JAnnotationArrayMember) getAnnotation(targetClass,
                        xmlTypeModelClass).getAnnotationMembers().get("propOrder");

            if (propOrderValue != null) {
              for (JAnnotationValue annotationValue : propOrderValue.annotations()) {
                if (oldFieldName.equals(generableToString(annotationValue))) {
                  setPrivateField(annotationValue, "value", JExpr.lit(fieldName));
                  break;
                }
              }
            }
          }
        }

        // Transform the field accordingly.
        originalImplField.type(collectionInterfaceClass);

        // If instantiation is specified to be "early", add code for creating new instance of the collection class.
        if (fieldConfiguration.getInstantiationMode() == Configuration.InstantiationMode.EARLY) {
          logger.debug("Applying EARLY instantiation...");
          // GENERATED CODE: ... fieldName = new C<T>();
          originalImplField.init(JExpr._new(collectionImplClass));
        }

        // Annotate the field with the @XmlElementWrapper annotation using the original field name.
        JAnnotationUse xmlElementWrapperAnnotation = originalImplField.annotate(xmlElementWrapperModelClass);
        JAnnotationUse xmlElementOriginalAnnotation = getAnnotation(originalImplField, xmlElementModelClass);

        // xmlElementOriginalAnnotation can be null:
        JExpression wrapperXmlName = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "name");
        if (wrapperXmlName != null) {
          xmlElementWrapperAnnotation.param("name", wrapperXmlName);
        }
        else if (fieldConfiguration.isApplyPluralForm()) {
          xmlElementWrapperAnnotation.param("name", getXsdDeclaration(fieldPropertyInfo).getName());
        }

        JExpression wrapperXmlRequired = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "required");
        if (wrapperXmlRequired != null) {
          xmlElementWrapperAnnotation.param("required", wrapperXmlRequired);
        }

        JExpression wrapperXmlNillable = getAnnotationMemberExpression(xmlElementOriginalAnnotation, "nillable");
        if (wrapperXmlNillable != null) {
          xmlElementWrapperAnnotation.param("nillable", wrapperXmlNillable);
        }

        // Namespace of the wrapper element
        JExpression wrapperXmlNamespace = getAnnotationMemberExpression(xmlElementOriginalAnnotation,
                    "namespace");
        if (wrapperXmlNamespace != null) {
          xmlElementWrapperAnnotation.param("namespace", wrapperXmlNamespace);
        }

        if (xmlElementOriginalAnnotation != null) {
          removeAnnotation(originalImplField, xmlElementOriginalAnnotation);
        }

        boolean xmlElementInfoWasTransferred = false;

        // Transfer @XmlAnyElement, @XmlElementRefs, @XmlElements:
        for (JClass annotationModelClass : new JClass[] { xmlAnyElementModelClass, xmlMixedModelClass,
                xmlElementRefModelClass, xmlElementRefsModelClass, xmlElementsModelClass }) {
          JAnnotationUse annotation = getAnnotation(candidate.getField(), annotationModelClass);

          if (annotation != null) {
            if (candidate.getFieldTargetNamespace() != null) {
              JAnnotationArrayMember annotationArrayMember = (JAnnotationArrayMember) getAnnotationMember(
                          annotation, "value");

              if (annotationArrayMember != null) {
                for (JAnnotationUse subAnnotation : annotationArrayMember.annotations()) {
                  if (getAnnotationMemberExpression(subAnnotation, "namespace") == null) {
                    subAnnotation.param("namespace", candidate.getFieldTargetNamespace());
                  }
                }
              }
View Full Code Here

*/
public class Jackson1Annotator extends AbstractAnnotator {

    @Override
    public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) {
        JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value");

        for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) {
            annotationValue.param(properties.next());
        }
    }
View Full Code Here

*/
public class Jackson2Annotator extends AbstractAnnotator {

    @Override
    public void propertyOrder(JDefinedClass clazz, JsonNode propertiesNode) {
        JAnnotationArrayMember annotationValue = clazz.annotate(JsonPropertyOrder.class).paramArray("value");

        for (Iterator<String> properties = propertiesNode.fieldNames(); properties.hasNext();) {
            annotationValue.param(properties.next());
        }
    }
View Full Code Here

      {
         xmlTypeAnnotation.param("namespace", xmlTypeNS);
      }
      if (propertyOrder != null)
      {
         JAnnotationArrayMember paramArray = xmlTypeAnnotation.paramArray("propOrder");
         for (String property : propertyOrder)
         {
            paramArray.param(property);
         }
      }

      // define XmlAccessorType class annotation
      JAnnotationUse xmlAccessorTypeAnnotation = clazz.annotate(XmlAccessorType.class);
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JAnnotationArrayMember

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.