当前位置: 首页>>代码示例>>Java>>正文


Java JAnnotatable类代码示例

本文整理汇总了Java中com.sun.codemodel.JAnnotatable的典型用法代码示例。如果您正苦于以下问题:Java JAnnotatable类的具体用法?Java JAnnotatable怎么用?Java JAnnotatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JAnnotatable类属于com.sun.codemodel包,在下文中一共展示了JAnnotatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: annotate

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
/**
 * Annotate the field according to the recipes given as {@link CPropertyInfo}.
 */
protected void annotate( JAnnotatable field ) {

    assert(field!=null);

    if (prop instanceof CAttributePropertyInfo) {
        annotateAttribute(field);
    } else if (prop instanceof CElementPropertyInfo) {
        annotateElement(field);
    } else if (prop instanceof CValuePropertyInfo) {
        field.annotate(XmlValue.class);
    } else if (prop instanceof CReferencePropertyInfo) {
        annotateReference(field);
    }

    outline.parent().generateAdapterIfNecessary(prop,field);
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:20,代码来源:AbstractField.java

示例2: setDeprecatedAnnotationAndJavadoc

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
private void setDeprecatedAnnotationAndJavadoc(Object deprecatedProp,
                                               JAnnotatable annotatable,
                                               JDocCommentable commentable)
{
  if (Boolean.TRUE.equals(deprecatedProp) && annotatable != null)
  {
    annotatable.annotate(Deprecated.class);
  }
  else if (deprecatedProp instanceof String)
  {
    if (commentable != null)
    {
      String deprecatedReason = (String)deprecatedProp;
      commentable.javadoc().addDeprecated().append(deprecatedReason);
    }
    if (annotatable != null)
    {
      annotatable.annotate(Deprecated.class);
    }
  }
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:22,代码来源:DataTemplateGenerator.java

示例3: annotate

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
public void annotate(JCodeModel codeModel, JAnnotatable annotatable,
		XAnnotation<?> xannotation) {
	final JClass annotationClass = codeModel.ref(xannotation
			.getAnnotationClass());
	JAnnotationUse annotationUse = null;
	for (JAnnotationUse annotation : annotatable.annotations()) {
		if (annotationClass.equals(annotation.getAnnotationClass())) {
			annotationUse = annotation;
		}
	}
	if (annotationUse == null) {
		annotationUse = annotatable.annotate(annotationClass);
	}
	final XAnnotationFieldVisitor<?> visitor = createAnnotationFieldVisitor(
			codeModel, annotationUse);
	for (XAnnotationField<?> field : xannotation.getFieldsList()) {
		field.accept(visitor);
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:20,代码来源:Annotator.java

示例4: annotateElementOutline

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotateElementOutline(final JCodeModel codeModel,
		final ElementOutline elementOutline,
		final CCustomizations customizations,
		final ErrorHandler errorHandler) {
	for (final CPluginCustomization customization : customizations) {
		final Element element = customization.element;
		final QName name = new QName(element.getNamespaceURI(),
				element.getLocalName());
		if (Constants.NAMESPACE_URI.equals(name.getNamespaceURI())) {
			customization.markAsAcknowledged();
			final AnnotationTarget annotationTarget = AnnotationTarget
					.getAnnotationTarget(element, AnnotationTarget.ELEMENT);
			try {
				final JAnnotatable annotatable = annotationTarget
						.getAnnotatable(elementOutline.parent(),
								elementOutline);
				annotate(codeModel, errorHandler, customization, element,
						annotatable);
			} catch (IllegalArgumentException iaex) {
				logger.error("Error applying the annotation.", iaex);
			}
		}
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:25,代码来源:AnnotatePlugin.java

示例5: annotateEnumOutline

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotateEnumOutline(final JCodeModel codeModel,
		final EnumOutline enumOutline,
		final CCustomizations customizations,
		final ErrorHandler errorHandler) {
	for (final CPluginCustomization customization : customizations) {
		final Element element = customization.element;
		final QName name = new QName(element.getNamespaceURI(),
				element.getLocalName());
		if (Constants.NAMESPACE_URI.equals(name.getNamespaceURI())) {
			customization.markAsAcknowledged();
			final AnnotationTarget annotationTarget = AnnotationTarget
					.getAnnotationTarget(element, AnnotationTarget.ENUM);
			try {
				final JAnnotatable annotatable = annotationTarget
						.getAnnotatable(enumOutline.parent(), enumOutline);
				annotate(codeModel, errorHandler, customization, element,
						annotatable);
			} catch (IllegalArgumentException iaex) {
				logger.error("Error applying the annotation.", iaex);
			}
		}
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:24,代码来源:AnnotatePlugin.java

示例6: annotateEnumConstantOutline

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotateEnumConstantOutline(final JCodeModel codeModel,
		final Outline outline,
		final EnumConstantOutline enumConstantOutline,
		final CCustomizations customizations,
		final ErrorHandler errorHandler) {
	for (final CPluginCustomization customization : customizations) {
		final Element element = customization.element;
		final QName name = new QName(element.getNamespaceURI(),
				element.getLocalName());
		if (Constants.NAMESPACE_URI.equals(name.getNamespaceURI())) {
			customization.markAsAcknowledged();
			final AnnotationTarget annotationTarget = AnnotationTarget
					.getAnnotationTarget(element,
							AnnotationTarget.ENUM_CONSTANT);
			try {
				final JAnnotatable annotatable = annotationTarget
						.getAnnotatable(outline, enumConstantOutline);
				annotate(codeModel, errorHandler, customization, element,
						annotatable);
			} catch (IllegalArgumentException iaex) {
				logger.error("Error applying the annotation.", iaex);
			}

		}
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:27,代码来源:AnnotatePlugin.java

示例7: annotateClassOutline

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotateClassOutline(final JCodeModel codeModel,
		final ClassOutline classOutline,
		final CCustomizations customizations, ErrorHandler errorHandler) {
	for (final CPluginCustomization customization : customizations) {
		final Element element = customization.element;
		final QName name = new QName(element.getNamespaceURI(),
				element.getLocalName());
		if (Constants.NAMESPACE_URI.equals(name.getNamespaceURI())) {
			customization.markAsAcknowledged();
			final AnnotationTarget annotationTarget = AnnotationTarget
					.getAnnotationTarget(element, AnnotationTarget.CLASS);
			try {
				final JAnnotatable annotatable = annotationTarget
						.getAnnotatable(classOutline.parent(), classOutline);
				annotate(codeModel, errorHandler, customization, element,
						annotatable);
			} catch (IllegalArgumentException iaex) {
				logger.error("Error applying the annotation.", iaex);
			}
		}
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:23,代码来源:AnnotatePlugin.java

示例8: annotate

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotate(final JAnnotatable annotatable, final Iterable<Annotation> annotationConfigurations)
    throws CreationException {
  ensureThatArgument(annotatable, notNull());
  ensureThatArgument(annotationConfigurations, notNull());
  for (final Annotation annotationConfiguration : annotationConfigurations) {
    annotate(annotatable, annotationConfiguration);
  }
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:9,代码来源:AbstractSourceFactory.java

示例9: addHttpMethodAnnotation

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
/**
 * <p>addHttpMethodAnnotation.</p>
 *
 * @param httpMethod a {@link java.lang.String} object.
 * @param annotatable a {@link com.sun.codemodel.JAnnotatable} object.
 * @return a {@link org.raml.jaxrs.codegen.core.Context} object.
 * @throws java.lang.Exception if any.
 */
@SuppressWarnings("unchecked")
public Context addHttpMethodAnnotation(final String httpMethod, final JAnnotatable annotatable)
    throws Exception
{
    final Object annotationClass = httpMethodAnnotations.get(httpMethod.toUpperCase());
    if (annotationClass == null)
    {
        final JDefinedClass annotationClazz = createCustomHttpMethodAnnotation(httpMethod);
        annotatable.annotate(annotationClazz);
    }
    else if (annotationClass instanceof JClass)
    {
        annotatable.annotate((JClass) annotationClass);
    }
    else if (annotationClass instanceof Class)
    {
        annotatable.annotate((Class<? extends Annotation>) annotationClass);
    }
    else
    {
        throw new IllegalStateException("Found annotation: " + annotationClass + " for HTTP method: "
                                        + httpMethod);
    }

    return this;
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:35,代码来源:Context.java

示例10: processConfig

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void processConfig(AnnotationGenerationInfo annotationGenerationInfo, ISimpleFacet si,
		PropertyCustomizerParameters cp) {
	JAnnotatable annotable = cp.getter;
	JAnnotationUse use = null;
	for (JAnnotationUse u : annotable.annotations()) {
		if (u.getAnnotationClass().fullName().equals(annotationGenerationInfo.annotationClassName)) {
			use = u;
			break;
		}
	}
	if (use == null) {
		use = annotable.annotate(writer.getModel().ref(annotationGenerationInfo.annotationClassName));
	}
	writer.addParam(use, si.value(), annotationGenerationInfo.annotationMemberName);
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:16,代码来源:FacetProcessingConfig.java

示例11: addHttpMethodAnnotation

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
private void addHttpMethodAnnotation(final String httpMethod, final JAnnotatable annotatable) {
    Class<? extends Annotation> annotationClass = httpMethodAnnotations
        .get(httpMethod.toUpperCase());
    if (annotationClass == null) {
        throw new IllegalArgumentException("unsupported HTTP method: " + httpMethod);
    }
    annotatable.annotate(annotationClass);
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:9,代码来源:ResourceGeneratingApiVisitor.java

示例12: getXew

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:13,代码来源:AbstractField.java

示例13: annotateAttribute

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
/**
 * Annotate the attribute property 'field'
 */
private void annotateAttribute(JAnnotatable field) {
    CAttributePropertyInfo ap = (CAttributePropertyInfo) prop;
    QName attName = ap.getXmlName();

    // [RESULT]
    // @XmlAttribute(name="foo", required=true, namespace="bar://baz")
    XmlAttributeWriter xaw = field.annotate2(XmlAttributeWriter.class);

    final String generatedName = attName.getLocalPart();
    final String generatedNS = attName.getNamespaceURI();

    // generate name property?
    if(!generatedName.equals(ap.getName(false))) {
        xaw.name(generatedName);
    }

    // generate namespace property?
    if(!generatedNS.equals("")) { // assume attributeFormDefault == unqualified
        xaw.namespace(generatedNS);
    }

    // generate required property?
    if(ap.isRequired()) {
        xaw.required(true);
    }
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:30,代码来源:AbstractField.java

示例14: annotate

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotate(final JCodeModel codeModel,
		final FieldOutline fieldOutline,
		final CCustomizations customizations, ErrorHandler errorHandler) {
	for (final CPluginCustomization customization : customizations) {
		final Element element = customization.element;
		final QName name = new QName(element.getNamespaceURI(),
				element.getLocalName());
		if (Constants.NAMESPACE_URI.equals(name.getNamespaceURI())) {
			customization.markAsAcknowledged();

			final AnnotationTarget annotationTarget = AnnotationTarget
					.getAnnotationTarget(element, AnnotationTarget
							.getAnnotationTarget(getDefaultFieldTarget()));

			try {
				final JAnnotatable annotatable = annotationTarget
						.getAnnotatable(fieldOutline.parent().parent(),
								fieldOutline);
				annotate(codeModel, errorHandler, customization, element,
						annotatable);
			} catch (IllegalArgumentException iaex) {
				logger.error("Error applying the annotation.", iaex);
			}

		}
	}
}
 
开发者ID:highsource,项目名称:jaxb2-annotate-plugin,代码行数:28,代码来源:AnnotatePlugin.java

示例15: annotate

import com.sun.codemodel.JAnnotatable; //导入依赖的package包/类
protected void annotate(JAnnotatable annotatable) {
	this.propertyInfo
			.acceptPropertyInfoVisitor(new AnnotatePropertyVisitor(
					annotatable));
}
 
开发者ID:highsource,项目名称:jaxb2-basics,代码行数:6,代码来源:AbstractPropertyOutline.java


注:本文中的com.sun.codemodel.JAnnotatable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。