javassist.bytecode.annotation.ShortMemberValue Java Examples
The following examples show how to use
javassist.bytecode.annotation.ShortMemberValue.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JValidator.java From dubbo-2.6.5 with Apache License 2.0 | 5 votes |
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) ((BooleanMemberValue) memberValue).setValue((Boolean) value); else if (memberValue instanceof ByteMemberValue) ((ByteMemberValue) memberValue).setValue((Byte) value); else if (memberValue instanceof CharMemberValue) ((CharMemberValue) memberValue).setValue((Character) value); else if (memberValue instanceof ShortMemberValue) ((ShortMemberValue) memberValue).setValue((Short) value); else if (memberValue instanceof IntegerMemberValue) ((IntegerMemberValue) memberValue).setValue((Integer) value); else if (memberValue instanceof LongMemberValue) ((LongMemberValue) memberValue).setValue((Long) value); else if (memberValue instanceof FloatMemberValue) ((FloatMemberValue) memberValue).setValue((Float) value); else if (memberValue instanceof DoubleMemberValue) ((DoubleMemberValue) memberValue).setValue((Double) value); else if (memberValue instanceof ClassMemberValue) ((ClassMemberValue) memberValue).setValue(((Class<?>) value).getName()); else if (memberValue instanceof StringMemberValue) ((StringMemberValue) memberValue).setValue((String) value); else if (memberValue instanceof EnumMemberValue) ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name()); /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) memberValue).setValue(members); } return memberValue; }
Example #2
Source File: ClassGenerator.java From flower with Apache License 2.0 | 5 votes |
private MemberValue getMemberValue(Object obj, ConstPool cp) { if (obj == null) { return null; } if (obj instanceof Integer) { return new IntegerMemberValue(cp, (Integer) obj); } else if (obj instanceof Boolean) { return new BooleanMemberValue((Boolean) obj, cp); } else if (obj instanceof Double) { return new DoubleMemberValue((Double) obj, cp); } else if (obj instanceof Float) { return new FloatMemberValue((Float) obj, cp); } else if (obj instanceof Short) { return new ShortMemberValue((Short) obj, cp); } else if (obj instanceof String) { return new StringMemberValue((String) obj, cp); } else if (obj instanceof String[]) { String[] oo = (String[]) obj; MemberValue[] memberValues = new MemberValue[oo.length]; ArrayMemberValue value = new ArrayMemberValue(cp); for (int i = 0; i < oo.length; i++) { memberValues[i] = getMemberValue(oo[i], cp); } value.setValue(memberValues); return value; } else if (obj instanceof Byte) { return new ByteMemberValue((Byte) obj, cp); } else if (obj instanceof Annotation) { return new AnnotationMemberValue((Annotation) obj, cp); } else if (obj instanceof ArrayMemberValue) { return new ArrayMemberValue((MemberValue) obj, cp); } else if (obj instanceof Character) { return new CharMemberValue((char) obj, cp); } else if (obj instanceof Long) { return new LongMemberValue((Long) obj, cp); } return null; }
Example #3
Source File: JValidator.java From dubbox with Apache License 2.0 | 5 votes |
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) ((BooleanMemberValue) memberValue).setValue((Boolean) value); else if (memberValue instanceof ByteMemberValue) ((ByteMemberValue) memberValue).setValue((Byte) value); else if (memberValue instanceof CharMemberValue) ((CharMemberValue) memberValue).setValue((Character) value); else if (memberValue instanceof ShortMemberValue) ((ShortMemberValue) memberValue).setValue((Short) value); else if (memberValue instanceof IntegerMemberValue) ((IntegerMemberValue) memberValue).setValue((Integer) value); else if (memberValue instanceof LongMemberValue) ((LongMemberValue) memberValue).setValue((Long) value); else if (memberValue instanceof FloatMemberValue) ((FloatMemberValue) memberValue).setValue((Float) value); else if (memberValue instanceof DoubleMemberValue) ((DoubleMemberValue) memberValue).setValue((Double) value); else if (memberValue instanceof ClassMemberValue) ((ClassMemberValue) memberValue).setValue(((Class<?>)value).getName()); else if (memberValue instanceof StringMemberValue) ((StringMemberValue) memberValue).setValue((String) value); else if (memberValue instanceof EnumMemberValue) ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name()); /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i ++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) memberValue).setValue(members); } return memberValue; }
Example #4
Source File: JValidator.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) ((BooleanMemberValue) memberValue).setValue((Boolean) value); else if (memberValue instanceof ByteMemberValue) ((ByteMemberValue) memberValue).setValue((Byte) value); else if (memberValue instanceof CharMemberValue) ((CharMemberValue) memberValue).setValue((Character) value); else if (memberValue instanceof ShortMemberValue) ((ShortMemberValue) memberValue).setValue((Short) value); else if (memberValue instanceof IntegerMemberValue) ((IntegerMemberValue) memberValue).setValue((Integer) value); else if (memberValue instanceof LongMemberValue) ((LongMemberValue) memberValue).setValue((Long) value); else if (memberValue instanceof FloatMemberValue) ((FloatMemberValue) memberValue).setValue((Float) value); else if (memberValue instanceof DoubleMemberValue) ((DoubleMemberValue) memberValue).setValue((Double) value); else if (memberValue instanceof ClassMemberValue) ((ClassMemberValue) memberValue).setValue(((Class<?>)value).getName()); else if (memberValue instanceof StringMemberValue) ((StringMemberValue) memberValue).setValue((String) value); else if (memberValue instanceof EnumMemberValue) ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name()); /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i ++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) memberValue).setValue(members); } return memberValue; }
Example #5
Source File: JValidator.java From dubbox with Apache License 2.0 | 5 votes |
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) ((BooleanMemberValue) memberValue).setValue((Boolean) value); else if (memberValue instanceof ByteMemberValue) ((ByteMemberValue) memberValue).setValue((Byte) value); else if (memberValue instanceof CharMemberValue) ((CharMemberValue) memberValue).setValue((Character) value); else if (memberValue instanceof ShortMemberValue) ((ShortMemberValue) memberValue).setValue((Short) value); else if (memberValue instanceof IntegerMemberValue) ((IntegerMemberValue) memberValue).setValue((Integer) value); else if (memberValue instanceof LongMemberValue) ((LongMemberValue) memberValue).setValue((Long) value); else if (memberValue instanceof FloatMemberValue) ((FloatMemberValue) memberValue).setValue((Float) value); else if (memberValue instanceof DoubleMemberValue) ((DoubleMemberValue) memberValue).setValue((Double) value); else if (memberValue instanceof ClassMemberValue) ((ClassMemberValue) memberValue).setValue(((Class<?>)value).getName()); else if (memberValue instanceof StringMemberValue) ((StringMemberValue) memberValue).setValue((String) value); else if (memberValue instanceof EnumMemberValue) ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name()); /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i ++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) memberValue).setValue(members); } return memberValue; }
Example #6
Source File: JValidator.java From dubbox with Apache License 2.0 | 5 votes |
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException { MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type); if (memberValue instanceof BooleanMemberValue) ((BooleanMemberValue) memberValue).setValue((Boolean) value); else if (memberValue instanceof ByteMemberValue) ((ByteMemberValue) memberValue).setValue((Byte) value); else if (memberValue instanceof CharMemberValue) ((CharMemberValue) memberValue).setValue((Character) value); else if (memberValue instanceof ShortMemberValue) ((ShortMemberValue) memberValue).setValue((Short) value); else if (memberValue instanceof IntegerMemberValue) ((IntegerMemberValue) memberValue).setValue((Integer) value); else if (memberValue instanceof LongMemberValue) ((LongMemberValue) memberValue).setValue((Long) value); else if (memberValue instanceof FloatMemberValue) ((FloatMemberValue) memberValue).setValue((Float) value); else if (memberValue instanceof DoubleMemberValue) ((DoubleMemberValue) memberValue).setValue((Double) value); else if (memberValue instanceof ClassMemberValue) ((ClassMemberValue) memberValue).setValue(((Class<?>)value).getName()); else if (memberValue instanceof StringMemberValue) ((StringMemberValue) memberValue).setValue((String) value); else if (memberValue instanceof EnumMemberValue) ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name()); /* else if (memberValue instanceof AnnotationMemberValue) */ else if (memberValue instanceof ArrayMemberValue) { CtClass arrayType = type.getComponentType(); int len = Array.getLength(value); MemberValue[] members = new MemberValue[len]; for (int i = 0; i < len; i ++) { members[i] = createMemberValue(cp, arrayType, Array.get(value, i)); } ((ArrayMemberValue) memberValue).setValue(members); } return memberValue; }
Example #7
Source File: ClassPathScanner.java From Bats with Apache License 2.0 | 4 votes |
@Override public void visitShortMemberValue(ShortMemberValue node) { values.add(String.valueOf(node.getValue())); }
Example #8
Source File: ServiceDelegateBuilder.java From jweb-cms with GNU Affero General Public License v3.0 | 4 votes |
private MemberValue memberValue(Class<?> type, Object value) { if (type.isArray()) { Object[] array = (Object[]) value; MemberValue[] memberValues = new MemberValue[array.length]; Class<?> componentType = type.getComponentType(); for (int i = 0; i < array.length; i++) { memberValues[i] = memberValue(componentType, array[i]); } ArrayMemberValue arrayMemberValue = new ArrayMemberValue(constPool); arrayMemberValue.setValue(memberValues); return arrayMemberValue; } else { if (type == int.class) { return new IntegerMemberValue(constPool, (int) value); } else if (long.class.equals(type)) { return new LongMemberValue((long) value, constPool); } else if (short.class.equals(type)) { return new ShortMemberValue((short) value, constPool); } else if (byte.class.equals(type)) { return new ByteMemberValue((byte) value, constPool); } else if (char.class.equals(type)) { return new CharMemberValue((char) value, constPool); } else if (float.class.equals(type)) { return new FloatMemberValue((float) value, constPool); } else if (double.class.equals(type)) { return new DoubleMemberValue((double) value, constPool); } else if (String.class.equals(type)) { return new StringMemberValue((String) value, constPool); } else if (boolean.class.equals(type)) { return new BooleanMemberValue((boolean) value, constPool); } else if (Class.class.equals(type)) { return new ClassMemberValue(((Class) value).getName(), constPool); } else if (Enum.class.isAssignableFrom(type)) { EnumMemberValue enumMemberValue = new EnumMemberValue(constPool); enumMemberValue.setType(type.getName()); enumMemberValue.setValue(((Enum) value).name()); return enumMemberValue; } else { throw new ApplicationException("unsupported annotation method type, type={}", type); } } }
Example #9
Source File: ClassExtractorAnnotationMemberValue.java From smart-testing with Apache License 2.0 | 4 votes |
@Override public void visitShortMemberValue(ShortMemberValue node) { }
Example #10
Source File: ClassPathScanner.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override public void visitShortMemberValue(ShortMemberValue node) { values.add(String.valueOf(node.getValue())); }