int annotation(int pos, int type, int numPairs) throws Exception { currentAnno = new Annotation(type, pool); return super.annotation(pos, type, numPairs); }
@Override int annotation(int pos, int type, int numPairs) throws Exception { currentAnno = new Annotation(type, pool); return super.annotation(pos, type, numPairs); }
@Override public DynamicField request() { Annotation annot = new Annotation(Request.class.getName(), cpool); attr.addAnnotation(annot); return this; }
@Override public DynamicField text(boolean own) { Annotation annot = new Annotation(Text.class.getName(), cpool); annot.addMemberValue("own", new BooleanMemberValue(own, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField ajax(String url) { Annotation annot = new Annotation(Ajax.class.getName(), cpool); annot.addMemberValue("url", new StringMemberValue(url, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField jsonpath(String value) { Annotation annot = new Annotation(JSONPath.class.getName(), cpool); annot.addMemberValue("value", new StringMemberValue(value, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField renderName(String value) { Annotation renderName = new Annotation(FieldRenderName.class.getName(), cpool); renderName.addMemberValue("value", new StringMemberValue(value, cpool)); attr.addAnnotation(renderName); return this; }
@Override public DynamicField requestParameter(String param) { Annotation annot = new Annotation(RequestParameter.class.getName(), cpool); annot.addMemberValue("value", new StringMemberValue(param, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField csspath(String cssPath) { Annotation annot = new Annotation(HtmlField.class.getName(), cpool); annot.addMemberValue("cssPath", new StringMemberValue(cssPath, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField html(boolean outer) { Annotation annot = new Annotation(Html.class.getName(), cpool); annot.addMemberValue("outer", new BooleanMemberValue(outer, cpool)); attr.addAnnotation(annot); return this; }
@Override public DynamicField attr(String value) { Annotation annot = new Annotation(Attr.class.getName(), cpool); annot.addMemberValue("value", new StringMemberValue(value, cpool)); attr.addAnnotation(annot); return this; }
for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { javassist.bytecode.annotation.Annotation ja = new javassist.bytecode.annotation.Annotation( classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName())); Method[] members = annotation.annotationType().getMethods();
for (Annotation annotation : annotations) { if (annotation.annotationType().isAnnotationPresent(Constraint.class)) { javassist.bytecode.annotation.Annotation ja = new javassist.bytecode.annotation.Annotation( classFile.getConstPool(), pool.getCtClass(annotation.annotationType().getName())); Method[] members = annotation.annotationType().getMethods();
protected Annotation getEntityListeners(ConstPool constantPool, Annotation existingEntityListeners, Annotation templateEntityListeners) { Annotation listeners = new Annotation(EntityListeners.class.getName(), constantPool); ArrayMemberValue listenerArray = new ArrayMemberValue(constantPool); Set<MemberValue> listenerMemberValues = new HashSet<>(); { ArrayMemberValue templateListenerValues = (ArrayMemberValue) templateEntityListeners.getMemberValue("value"); listenerMemberValues.addAll(Arrays.asList(templateListenerValues.getValue())); logger.debug("Adding template values to new EntityListeners"); } if (existingEntityListeners != null) { ArrayMemberValue oldListenerValues = (ArrayMemberValue) existingEntityListeners.getMemberValue("value"); listenerMemberValues.addAll(Arrays.asList(oldListenerValues.getValue())); logger.debug("Adding previous values to new EntityListeners"); } listenerArray.setValue(listenerMemberValues.toArray(new MemberValue[listenerMemberValues.size()])); listeners.addMemberValue("value", listenerArray); return listeners; }
private static void addAnnotations(FieldInfo fieldInfo, Class<?>[] annotations) { AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) fieldInfo.getAttribute( AnnotationsAttribute.visibleTag ); if ( annotationsAttribute == null ) { annotationsAttribute = new AnnotationsAttribute( fieldInfo.getConstPool(), AnnotationsAttribute.visibleTag ); fieldInfo.addAttribute( annotationsAttribute ); } for (Class<?> annotation : annotations) { annotationsAttribute.addAnnotation( new Annotation( annotation.getName(), fieldInfo.getConstPool() ) ); } }
@Override public DynamicField jsvar(String var, String jsonpath) { Annotation annot = new Annotation(JSVar.class.getName(), cpool); annot.addMemberValue("var", new StringMemberValue(var, cpool)); annot.addMemberValue("jsonpath", new StringMemberValue(jsonpath, cpool)); attr.addAnnotation(annot); return this; }
@SneakyThrows public Proxy<I> addField(String code, Class<? extends java.lang.annotation.Annotation> annotation, Map<String, Object> annotationProperties) { return handleException(() -> { CtField ctField = CtField.make(code, ctClass); if (null != annotation) { ConstPool constPool = ctClass.getClassFile().getConstPool(); AnnotationsAttribute attributeInfo = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); Annotation ann = new javassist.bytecode.annotation.Annotation(annotation.getName(), constPool); if (null != annotationProperties) { annotationProperties.forEach((key, value) -> { MemberValue memberValue = createMemberValue(value, constPool); if (memberValue != null) { ann.addMemberValue(key, memberValue); } }); } attributeInfo.addAnnotation(ann); ctField.getFieldInfo().addAttribute(attributeInfo); } ctClass.addField(ctField); }); }
@Override public DynamicField href(boolean click, String... value) { Annotation annot = new Annotation(Href.class.getName(), cpool); annot.addMemberValue("click", new BooleanMemberValue(click, cpool)); ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cpool); MemberValue[] memberValues = new StringMemberValue[value.length]; for(int i = 0; i < value.length; i++) { memberValues[i] = new StringMemberValue(value[i], cpool); } arrayMemberValue.setValue(memberValues); annot.addMemberValue("value", arrayMemberValue); attr.addAnnotation(annot); return this; }
@Override public DynamicField image(String download, String... value) { Annotation annot = new Annotation(Image.class.getName(), cpool); annot.addMemberValue("download", new StringMemberValue(download, cpool)); ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cpool); MemberValue[] memberValues = new StringMemberValue[value.length]; for(int i = 0; i < value.length; i++) { memberValues[i] = new StringMemberValue(value[i], cpool); } arrayMemberValue.setValue(memberValues); annot.addMemberValue("value", arrayMemberValue); attr.addAnnotation(annot); return this; }
Annotation info = new Annotation(cp, type); return new AnnotationMemberValue(info, cp);