public static AnnotationPropertyAccessorBuilder create() { return new AnnotationPropertyAccessorBuilder(); }
public static AnnotationPropertyAccessor createDynamicSerializer(final Class<? extends Annotation> annotationType) { final AnnotationPropertyAccessorBuilder builder = AnnotationPropertyAccessorBuilder.create(); final Collection<Method> annoAttrs = CDIAnnotationUtils.getAnnotationAttributes(annotationType); for (final Method attr : annoAttrs) { builder.with(attr.getName(), anno -> { try { final String retVal; final Function<Object, String> toString = componentToString( attr.getReturnType().isArray() ? attr.getReturnType().getComponentType() : attr.getReturnType()); if (attr.getReturnType().isArray()) { final StringBuilder sb = new StringBuilder(); final Object[] array = (Object[]) attr.invoke(anno); sb.append("["); for (final Object obj : array) { sb.append(toString.apply(obj)).append(","); } sb.replace(sb.length()-1, sb.length(), "]"); retVal = sb.toString(); } else { retVal = toString.apply(attr.invoke(anno)); } return retVal; } catch (final Exception e) { throw new RuntimeException(String.format("Could not access '%s' property while serializing %s.", attr.getName(), anno.annotationType()), e); } }); } return builder.build(); }
public AnnotationPropertyAccessor build() { return new AnnotationPropertyAccessor(createOrderedPropertyMap()); }
public static AnnotationPropertyAccessor createDynamicSerializer(final Class<? extends Annotation> annotationType) { final AnnotationPropertyAccessorBuilder builder = AnnotationPropertyAccessorBuilder.create(); final Collection<Method> annoAttrs = CDIAnnotationUtils.getAnnotationAttributes(annotationType); for (final Method attr : annoAttrs) { builder.with(attr.getName(), anno -> { try { final String retVal; final Function<Object, String> toString = componentToString( attr.getReturnType().isArray() ? attr.getReturnType().getComponentType() : attr.getReturnType()); if (attr.getReturnType().isArray()) { final StringBuilder sb = new StringBuilder(); final Object[] array = (Object[]) attr.invoke(anno); sb.append("["); for (final Object obj : array) { sb.append(toString.apply(obj)).append(","); } sb.replace(sb.length()-1, sb.length(), "]"); retVal = sb.toString(); } else { retVal = toString.apply(attr.invoke(anno)); } return retVal; } catch (final Exception e) { throw new RuntimeException(String.format("Could not access '%s' property while serializing %s.", attr.getName(), anno.annotationType()), e); } }); } return builder.build(); }
public AnnotationPropertyAccessor build() { return new AnnotationPropertyAccessor(createOrderedPropertyMap()); }
public static AnnotationPropertyAccessorBuilder create() { return new AnnotationPropertyAccessorBuilder(); }