本文整理了Java中javassist.bytecode.annotation.Annotation.getTypeName()
方法的一些代码示例,展示了Annotation.getTypeName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getTypeName()
方法的具体详情如下:
包路径:javassist.bytecode.annotation.Annotation
类名称:Annotation
方法名:getTypeName
[英]Obtains the name of the annotation type.
[中]获取批注类型的名称。
代码示例来源:origin: redisson/redisson
/**
* Obtains the name of the annotation type.
*
* @return the type name
*/
public String getTypeName() {
return annotation.getTypeName();
}
代码示例来源:origin: org.javassist/javassist
/**
* Obtains the name of the annotation type.
*
* @return the type name
*/
public String getTypeName() {
return annotation.getTypeName();
}
代码示例来源:origin: ronmamo/reflections
private List<String> getAnnotationNames(final Annotation[] annotations) {
List<String> result = Lists.newArrayList();
for (Annotation annotation : annotations) {
result.add(annotation.getTypeName());
}
return result;
}
代码示例来源:origin: org.reflections/reflections
private List<String> getAnnotationNames(final Annotation[] annotations) {
List<String> result = Lists.newArrayList();
for (Annotation annotation : annotations) {
result.add(annotation.getTypeName());
}
return result;
}
代码示例来源:origin: org.javassist/javassist
@Override
public int hashCode() {
return getTypeName().hashCode() +
(members == null ? 0 : members.hashCode());
}
代码示例来源:origin: redisson/redisson
Class getType(ClassLoader cl) throws ClassNotFoundException {
if (value == null)
throw new ClassNotFoundException("no type specified");
else
return loadClass(cl, value.getTypeName());
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected boolean containsTypeLevelPersistenceAnnotation(Annotation[] annotations) {
for (Annotation annotation : annotations) {
if (annotation.getTypeName().equals(Entity.class.getName())
|| annotation.getTypeName().equals(Embeddable.class.getName())
|| annotation.getTypeName().equals(MappedSuperclass.class.getName())) {
return true;
}
}
return false;
}
}
代码示例来源:origin: redisson/redisson
/**
* Returns true if the given object represents the same annotation
* as this object. The equality test checks the member values.
*/
public boolean equals(Object obj) {
if (obj == this)
return true;
if (obj == null || obj instanceof Annotation == false)
return false;
Annotation other = (Annotation) obj;
if (getTypeName().equals(other.getTypeName()) == false)
return false;
LinkedHashMap otherMembers = other.members;
if (members == otherMembers)
return true;
else if (members == null)
return otherMembers == null;
else
if (otherMembers == null)
return false;
else
return members.equals(otherMembers);
}
}
代码示例来源:origin: redisson/redisson
/**
* Parses the annotations and returns a data structure representing
* the annotation with the specified type. See also
* <code>getAnnotations()</code> as to the returned data structure.
*
* @param type the annotation type.
* @return null if the specified annotation type is not included.
* @see #getAnnotations()
*/
public Annotation getAnnotation(String type) {
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].getTypeName().equals(type))
return annotations[i];
}
return null;
}
代码示例来源:origin: redisson/redisson
/**
* Returns a string representation of the annotation.
*/
public String toString() {
StringBuffer buf = new StringBuffer("@");
buf.append(getTypeName());
if (members != null) {
buf.append("(");
Iterator mit = members.keySet().iterator();
while (mit.hasNext()) {
String name = (String)mit.next();
buf.append(name).append("=").append(getMemberValue(name));
if (mit.hasNext())
buf.append(", ");
}
buf.append(")");
}
return buf.toString();
}
代码示例来源:origin: ronmamo/reflections
private List<String> getAnnotationNames(final AnnotationsAttribute... annotationsAttributes) {
List<String> result = Lists.newArrayList();
if (annotationsAttributes != null) {
for (AnnotationsAttribute annotationsAttribute : annotationsAttributes) {
if (annotationsAttribute != null) {
for (Annotation annotation : annotationsAttribute.getAnnotations()) {
result.add(annotation.getTypeName());
}
}
}
}
return result;
}
代码示例来源:origin: org.javassist/javassist
@Override
Class<?> getType(ClassLoader cl) throws ClassNotFoundException {
if (value == null)
throw new ClassNotFoundException("no type specified");
return loadClass(cl, value.getTypeName());
}
代码示例来源:origin: org.reflections/reflections
private List<String> getAnnotationNames(final AnnotationsAttribute... annotationsAttributes) {
List<String> result = Lists.newArrayList();
if (annotationsAttributes != null) {
for (AnnotationsAttribute annotationsAttribute : annotationsAttributes) {
if (annotationsAttribute != null) {
for (Annotation annotation : annotationsAttribute.getAnnotations()) {
result.add(annotation.getTypeName());
}
}
}
}
return result;
}
代码示例来源:origin: redisson/redisson
/**
* Adds an annotation. If there is an annotation with the same type,
* it is removed before the new annotation is added.
*
* @param annotation the added annotation.
*/
public void addAnnotation(Annotation annotation) {
String type = annotation.getTypeName();
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].getTypeName().equals(type)) {
annotations[i] = annotation;
setAnnotations(annotations);
return;
}
}
Annotation[] newlist = new Annotation[annotations.length + 1];
System.arraycopy(annotations, 0, newlist, 0, annotations.length);
newlist[annotations.length] = annotation;
setAnnotations(newlist);
}
代码示例来源:origin: redisson/redisson
static boolean hasAnnotationType(String annotationTypeName, ClassPool cp,
AnnotationsAttribute a1,
AnnotationsAttribute a2)
{
Annotation[] anno1, anno2;
if (a1 == null)
anno1 = null;
else
anno1 = a1.getAnnotations();
if (a2 == null)
anno2 = null;
else
anno2 = a2.getAnnotations();
if (anno1 != null)
for (int i = 0; i < anno1.length; i++)
if (anno1[i].getTypeName().equals(annotationTypeName))
return true;
if (anno2 != null)
for (int i = 0; i < anno2.length; i++)
if (anno2[i].getTypeName().equals(annotationTypeName))
return true;
return false;
}
代码示例来源:origin: redisson/redisson
/**
* Get the annotation type
*
* @return the annotation class
* @throws NoClassDefFoundError when the class could not loaded
*/
private Class getAnnotationType() {
if (annotationType == null) {
String typeName = annotation.getTypeName();
try {
annotationType = classLoader.loadClass(typeName);
}
catch (ClassNotFoundException e) {
NoClassDefFoundError error = new NoClassDefFoundError("Error loading annotation class: " + typeName);
error.setStackTrace(e.getStackTrace());
throw error;
}
}
return annotationType;
}
代码示例来源:origin: redisson/redisson
/**
* Removes an annotation by type.
* After removing an annotation, if {@link #numAnnotations()} returns 0,
* this annotations attribute has to be removed.
*
* @param type of annotation to remove
* @return whether an annotation with the given type has been removed
* @since 3.21
*/
public boolean removeAnnotation(String type) {
Annotation[] annotations = getAnnotations();
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].getTypeName().equals(type)) {
Annotation[] newlist = new Annotation[annotations.length - 1];
System.arraycopy(annotations, 0, newlist, 0, i);
if (i < annotations.length - 1) {
System.arraycopy(annotations, i + 1, newlist, i,
annotations.length - i - 1);
}
setAnnotations(newlist);
return true;
}
}
return false;
}
代码示例来源:origin: redisson/redisson
static Object getAnnotationType(Class clz, ClassPool cp,
AnnotationsAttribute a1, AnnotationsAttribute a2)
throws ClassNotFoundException
{
Annotation[] anno1, anno2;
if (a1 == null)
anno1 = null;
else
anno1 = a1.getAnnotations();
if (a2 == null)
anno2 = null;
else
anno2 = a2.getAnnotations();
String typeName = clz.getName();
if (anno1 != null)
for (int i = 0; i < anno1.length; i++)
if (anno1[i].getTypeName().equals(typeName))
return toAnnoType(anno1[i], cp);
if (anno2 != null)
for (int i = 0; i < anno2.length; i++)
if (anno2[i].getTypeName().equals(typeName))
return toAnnoType(anno2[i], cp);
return null;
}
代码示例来源:origin: redisson/redisson
/**
* Constructs an annotation-type object representing this annotation.
* For example, if this annotation represents <code>@Author</code>,
* this method returns an <code>Author</code> object.
*
* @param cl class loader for loading an annotation type.
* @param cp class pool for obtaining class files.
* @return the annotation
* @throws ClassNotFoundException if the class cannot found.
* @throws NoSuchClassError if the class linkage fails.
*/
public Object toAnnotationType(ClassLoader cl, ClassPool cp)
throws ClassNotFoundException, NoSuchClassError
{
return AnnotationImpl.make(cl,
MemberValue.loadClass(cl, getTypeName()),
cp, this);
}
代码示例来源:origin: redisson/redisson
private static Object toAnnoType(Annotation anno, ClassPool cp)
throws ClassNotFoundException
{
try {
ClassLoader cl = cp.getClassLoader();
return anno.toAnnotationType(cl, cp);
}
catch (ClassNotFoundException e) {
ClassLoader cl2 = cp.getClass().getClassLoader();
try {
return anno.toAnnotationType(cl2, cp);
}
catch (ClassNotFoundException e2){
try {
Class clazz = cp.get(anno.getTypeName()).toClass();
return javassist.bytecode.annotation.AnnotationImpl.make(
clazz.getClassLoader(),
clazz, cp, anno);
}
catch (Throwable e3) {
throw new ClassNotFoundException(anno.getTypeName());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!