本文整理汇总了Java中org.jboss.jandex.DotName类的典型用法代码示例。如果您正苦于以下问题:Java DotName类的具体用法?Java DotName怎么用?Java DotName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DotName类属于org.jboss.jandex包,在下文中一共展示了DotName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHttpVerb
import org.jboss.jandex.DotName; //导入依赖的package包/类
private String getHttpVerb(MethodInfo method) {
getLog().debug("Getting http verb from method:");
getLog().debug(method.name());
List<AnnotationInstance> methodAnnotations = method.annotations();
for (AnnotationInstance annotation : methodAnnotations) {
DotName annotationName = annotation.name();
if (!annotationName.equals(PATH_ANNOTATION)) {
if (annotationName.equals(GET_ANNOTATION))
return "GET ";
if (annotationName.equals(POST_ANNOTATION))
return "POST ";
if (annotationName.equals(PUT_ANNOTATION))
return "PUT ";
if (annotationName.equals(DELETE_ANNOTATION))
return "DELETE ";
if (annotationName.equals(OPTIONS_ANNOTATION))
return "OPTIONS ";
if (annotationName.equals(HEAD_ANNOTATION))
return "HEAD ";
}
}
return null;
}
示例2: createDefaultCallback
import org.jboss.jandex.DotName; //导入依赖的package包/类
private void createDefaultCallback(Class callbackTypeClass,
DotName callbackTypeName,
String callbackClassName,
Map<Class<?>, String> callbacksByClass) {
for ( AnnotationInstance callback : getLocalBindingContext().getIndex().getAnnotations( callbackTypeName ) ) {
MethodInfo methodInfo = (MethodInfo) callback.target();
validateMethod( methodInfo, callbackTypeClass, callbacksByClass, true );
if ( methodInfo.declaringClass().name().toString().equals( callbackClassName ) ) {
if ( methodInfo.args().length != 1 ) {
throw new PersistenceException(
String.format(
"Callback method %s must have exactly one argument defined as either Object or %s in ",
methodInfo.name(),
getEntityName()
)
);
}
callbacksByClass.put( callbackTypeClass, methodInfo.name() );
}
}
}
示例3: createCallback
import org.jboss.jandex.DotName; //导入依赖的package包/类
private void createCallback(Class callbackTypeClass,
DotName callbackTypeName,
Map<Class<?>, String> callbacksByClass,
ClassInfo callbackClassInfo,
boolean isListener) {
Map<DotName, List<AnnotationInstance>> annotations = callbackClassInfo.annotations();
List<AnnotationInstance> annotationInstances = annotations.get( callbackTypeName );
if ( annotationInstances == null ) {
return;
}
for ( AnnotationInstance callbackAnnotation : annotationInstances ) {
MethodInfo methodInfo = (MethodInfo) callbackAnnotation.target();
validateMethod( methodInfo, callbackTypeClass, callbacksByClass, isListener );
callbacksByClass.put( callbackTypeClass, methodInfo.name() );
}
}
示例4: MappedAttribute
import org.jboss.jandex.DotName; //导入依赖的package包/类
MappedAttribute(String name, Class<?> attributeType, String accessType, Map<DotName, List<AnnotationInstance>> annotations, EntityBindingContext context) {
this.context = context;
this.annotations = annotations;
this.name = name;
this.attributeType = attributeType;
this.accessType = accessType;
//if this attribute has either @Id or @EmbeddedId, then it is an id attribute
AnnotationInstance idAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ID );
AnnotationInstance embeddedIdAnnotation = JandexHelper.getSingleAnnotation(
annotations,
JPADotNames.EMBEDDED_ID
);
isId = ( idAnnotation != null || embeddedIdAnnotation != null );
AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation(
annotations,
JPADotNames.COLUMN
);
columnValues = new ColumnValues( columnAnnotation );
this.isOptimisticLockable = checkOptimisticLockAnnotation();
}
示例5: getSingleAnnotation
import org.jboss.jandex.DotName; //导入依赖的package包/类
/**
* @param annotations List of annotation instances keyed against their dot name.
* @param annotationName the annotation to retrieve from map
*
* @return the single annotation of the specified dot name or {@code null} in case the annotation is not specified at all
*
* @throws org.hibernate.AssertionFailure in case there is there is more than one annotation of this type.
*/
public static AnnotationInstance getSingleAnnotation(Map<DotName, List<AnnotationInstance>> annotations, DotName annotationName)
throws AssertionFailure {
List<AnnotationInstance> annotationList = annotations.get( annotationName );
if ( annotationList == null ) {
return null;
}
else if ( annotationList.size() == 1 ) {
return annotationList.get( 0 );
}
else {
throw new AssertionFailure(
"Found more than one instance of the annotation "
+ annotationList.get( 0 ).name().toString()
+ ". Expected was one."
);
}
}
示例6: getMemberAnnotations
import org.jboss.jandex.DotName; //导入依赖的package包/类
public static Map<DotName, List<AnnotationInstance>> getMemberAnnotations(ClassInfo classInfo, String name) {
if ( classInfo == null ) {
throw new IllegalArgumentException( "classInfo cannot be null" );
}
if ( name == null ) {
throw new IllegalArgumentException( "name cannot be null" );
}
Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>();
for ( List<AnnotationInstance> annotationList : classInfo.annotations().values() ) {
for ( AnnotationInstance instance : annotationList ) {
String targetName = null;
if ( instance.target() instanceof FieldInfo ) {
targetName = ( (FieldInfo) instance.target() ).name();
}
else if ( instance.target() instanceof MethodInfo ) {
targetName = ( (MethodInfo) instance.target() ).name();
}
if ( targetName != null && name.equals( targetName ) ) {
addAnnotationToMap( instance, annotations );
}
}
}
return annotations;
}
示例7: findRootEntityClassInfo
import org.jboss.jandex.DotName; //导入依赖的package包/类
/**
* Finds the root entity starting at the entity given by {@code info}. The root entity is not the highest superclass
* in a java type sense, but the highest superclass which is also an entity (annotated w/ {@code @Entity}.
*
* @param index the annotation repository
* @param info the class info representing an entity
*
* @return Finds the root entity starting at the entity given by {@code info}
*/
private static ClassInfo findRootEntityClassInfo(Index index, ClassInfo info) {
ClassInfo rootEntity = info;
DotName superName = info.superName();
ClassInfo tmpInfo;
// walk up the hierarchy until java.lang.Object
while ( !OBJECT.equals( superName ) ) {
tmpInfo = index.getClassByName( superName );
if ( isEntityClass( tmpInfo ) ) {
rootEntity = tmpInfo;
}
superName = tmpInfo.superName();
}
return rootEntity;
}
示例8: getAccessFromIndex
import org.jboss.jandex.DotName; //导入依赖的package包/类
protected AccessType getAccessFromIndex(DotName className) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
List<AnnotationInstance> accessAnnotationInstances = indexedAnnotations.get( ACCESS );
if ( MockHelper.isNotEmpty( accessAnnotationInstances ) ) {
for ( AnnotationInstance annotationInstance : accessAnnotationInstances ) {
if ( annotationInstance.target() != null && annotationInstance.target() instanceof ClassInfo ) {
ClassInfo ci = (ClassInfo) ( annotationInstance.target() );
if ( className.equals( ci.name() ) ) {
//todo does ci need to have @Entity or @MappedSuperClass ??
return AccessType.valueOf( annotationInstance.value().asEnum() );
}
}
}
}
return null;
}
示例9: build
import org.jboss.jandex.DotName; //导入依赖的package包/类
/**
* Build new {@link Index} with mocked annotations from orm.xml.
* This method should be only called once per {@org.hibernate.metamodel.source.annotations.xml.mocker.IndexBuilder IndexBuilder} instance.
*
* @param globalDefaults Global defaults from <persistence-unit-metadata>, or null.
*
* @return Index.
*/
Index build(EntityMappingsMocker.Default globalDefaults) {
//merge annotations that not overrided by xml into the new Index
for ( ClassInfo ci : index.getKnownClasses() ) {
DotName name = ci.name();
if ( indexedClassInfoAnnotationsMap.containsKey( name ) ) {
//this class has been overrided by orm.xml
continue;
}
if ( ci.annotations() != null && !ci.annotations().isEmpty() ) {
Map<DotName, List<AnnotationInstance>> tmp = new HashMap<DotName, List<AnnotationInstance>>( ci.annotations() );
DefaultConfigurationHelper.INSTANCE.applyDefaults( tmp, globalDefaults );
mergeAnnotationMap( tmp, annotations );
classes.put( name, ci );
if ( ci.superName() != null ) {
addSubClasses( ci.superName(), ci );
}
if ( ci.interfaces() != null && ci.interfaces().length > 0 ) {
addImplementors( ci.interfaces(), ci );
}
}
}
return Index.create(
annotations, subclasses, implementors, classes
);
}
示例10: getIndexedAnnotations
import org.jboss.jandex.DotName; //导入依赖的package包/类
public Map<DotName, List<AnnotationInstance>> getIndexedAnnotations(DotName name) {
Map<DotName, List<AnnotationInstance>> map = indexedClassInfoAnnotationsMap.get( name );
if ( map == null ) {
ClassInfo ci = index.getClassByName( name );
if ( ci == null || ci.annotations() == null ) {
map = Collections.emptyMap();
}
else {
map = new HashMap<DotName, List<AnnotationInstance>>( ci.annotations() );
//here we ignore global annotations
for ( DotName globalAnnotationName : DefaultConfigurationHelper.GLOBAL_ANNOTATIONS ) {
if ( map.containsKey( globalAnnotationName ) ) {
map.put( globalAnnotationName, Collections.<AnnotationInstance>emptyList() );
}
}
}
indexedClassInfoAnnotationsMap.put( name, map );
}
return map;
}
示例11: addAnnotationInstance
import org.jboss.jandex.DotName; //导入依赖的package包/类
void addAnnotationInstance(DotName targetClassName, AnnotationInstance annotationInstance) {
if ( annotationInstance == null ) {
return;
}
for ( IndexedAnnotationFilter indexedAnnotationFilter : IndexedAnnotationFilter.ALL_FILTERS ) {
indexedAnnotationFilter.beforePush( this, targetClassName, annotationInstance );
}
Map<DotName, List<AnnotationInstance>> map = classInfoAnnotationsMap.get( targetClassName );
if ( map == null ) {
throw new AssertionFailure( "Can't find " + targetClassName + " in internal cache, should call createClassInfo first" );
}
List<AnnotationInstance> annotationInstanceList = map.get( annotationInstance.name() );
if ( annotationInstanceList == null ) {
annotationInstanceList = new ArrayList<AnnotationInstance>();
map.put( annotationInstance.name(), annotationInstanceList );
}
annotationInstanceList.add( annotationInstance );
}
示例12: mergeAnnotationMap
import org.jboss.jandex.DotName; //导入依赖的package包/类
private void mergeAnnotationMap(Map<DotName, List<AnnotationInstance>> source, Map<DotName, List<AnnotationInstance>> target) {
if ( source != null ) {
for ( Map.Entry<DotName, List<AnnotationInstance>> el : source.entrySet() ) {
if ( el.getValue().isEmpty() ) {
continue;
}
DotName annotationName = el.getKey();
List<AnnotationInstance> value = el.getValue();
List<AnnotationInstance> annotationInstanceList = target.get( annotationName );
if ( annotationInstanceList == null ) {
annotationInstanceList = new ArrayList<AnnotationInstance>();
target.put( annotationName, annotationInstanceList );
}
annotationInstanceList.addAll( value );
}
}
}
示例13: getAccessFromIdPosition
import org.jboss.jandex.DotName; //导入依赖的package包/类
static JaxbAccessType getAccessFromIdPosition(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
JaxbAccessType accessType = getAccessFromIdPosition( ormAnnotations );
if ( accessType == null ) {
accessType = getAccessFromIdPosition( indexedAnnotations );
}
if ( accessType == null ) {
ClassInfo parent = indexBuilder.getClassInfo( className );
if ( parent == null ) {
parent = indexBuilder.getIndexedClassInfo( className );
}
if ( parent != null ) {
DotName parentClassName = parent.superName();
accessType = getAccessFromIdPosition( parentClassName, indexBuilder );
}
}
return accessType;
}
示例14: getEntityAccess
import org.jboss.jandex.DotName; //导入依赖的package包/类
static JaxbAccessType getEntityAccess(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
JaxbAccessType accessType = getAccess( ormAnnotations );
if ( accessType == null ) {
accessType = getAccess( indexedAnnotations );
}
if ( accessType == null ) {
ClassInfo parent = indexBuilder.getClassInfo( className );
if ( parent == null ) {
parent = indexBuilder.getIndexedClassInfo( className );
}
if ( parent != null ) {
DotName parentClassName = parent.superName();
accessType = getEntityAccess( parentClassName, indexBuilder );
}
}
return accessType;
}
示例15: getAccess
import org.jboss.jandex.DotName; //导入依赖的package包/类
private static JaxbAccessType getAccess(Map<DotName, List<AnnotationInstance>> annotations) {
if ( annotations == null || annotations.isEmpty() || !isEntityObject( annotations ) ) {
return null;
}
List<AnnotationInstance> accessAnnotationInstances = annotations.get( JPADotNames.ACCESS );
if ( MockHelper.isNotEmpty( accessAnnotationInstances ) ) {
for ( AnnotationInstance annotationInstance : accessAnnotationInstances ) {
if ( annotationInstance.target() != null && annotationInstance.target() instanceof ClassInfo ) {
return JandexHelper.getEnumValue(
annotationInstance,
"value",
JaxbAccessType.class
);
}
}
}
return null;
}