public ValueCompositeTemplateModel( ValueComposite composite, ObjectWrapper wrapper ) { this.composite = composite; this.wrapper = wrapper; descriptor = (ValueDescriptor) Qi4j.FUNCTION_DESCRIPTOR_FOR.map( composite ); }
public static Iterable<Type> typesOf( Type type ) { return TYPES_OF.map( type ); }
public static Iterable<Type> interfacesOf( Type type ) { return INTERFACES_OF.map( type ); }
public static Type wrapperClass( Type type ) { return WRAPPER_CLASS.map( type ); }
public static Type typeOf( AccessibleObject from ) { return TYPE_OF.map( from ); }
public static Iterable<Class<?>> classHierarchy( Class<?> type ) { return CLASS_HIERARCHY.map( type ); }
@Override public boolean satisfiedBy( Type item ) { return Classes.RAW_CLASS.map( item ).getDeclaredMethods().length > 0; } };
@SuppressWarnings( "UnusedDeclaration" ) public static <AnnotationType extends Annotation> AnnotationType findAnnotationOfTypeOrAnyOfSuperTypes( Class<?> type, Class<AnnotationType> annotationClass ) { AnnotationType result = null; for( Type clazz : Classes.TYPES_OF.map( type ) ) { result = Classes.RAW_CLASS.map( clazz ).getAnnotation( annotationClass ); if( result != null ) { break; } } return result; }
public static boolean isMap( Type type ) { Class<?> cl = Classes.RAW_CLASS.map( type ); return Map.class.isAssignableFrom( cl ); }
@Override public String map( Type type ) { return RAW_CLASS.map( type ).getName(); } };
public static boolean isValueComposite( Type type ) { return ValueComposite.class.isAssignableFrom( Classes.RAW_CLASS.map( type ) ); }
public static boolean isCollection( Type type ) { Class<?> cl = Classes.RAW_CLASS.map( type ); return cl.equals( Collection.class ) || cl.equals( List.class ) || cl.equals( Set.class ); }
public static <T extends Annotation> T annotationOn( Type type, Class<T> annotationType ) { return annotationType.cast( Classes.RAW_CLASS.map( type ).getAnnotation( annotationType ) ); }
public ConstraintViolationException( String instanceToString, Iterable<Class<?>> instanceTypes, Member method, Collection<ConstraintViolation> violations ) { this.instanceToString = instanceToString; this.instanceTypes = instanceTypes; mixinTypeName = method.getDeclaringClass().getName(); methodName = method.getName(); this.constraintViolations = violations; }
@Override public Iterable<Method> map( Type type ) { return iterable( Classes.RAW_CLASS.map( type ).getDeclaredMethods() ); } } );
@Override public Iterable<Annotation> map( Type type ) { return Iterables.iterable( Classes.RAW_CLASS.map( type ).getAnnotations() ); } } );
public static TypeName nameOf( Type type ) { return nameOf( Classes.RAW_CLASS.map( type ) ); }
public void set( Object metaInfo ) { if( metaInfo instanceof Annotation ) { Annotation annotation = (Annotation) metaInfo; metaInfoMap.put( annotation.annotationType(), metaInfo ); } else { Class<?> metaInfoclass = metaInfo.getClass(); Iterable<Type> types = typesOf( metaInfoclass ); for( Type type : types ) { metaInfoMap.put( Classes.RAW_CLASS.map( type ), metaInfo ); } } }
@Override public TemplateCollectionModel values() throws TemplateModelException { return (TemplateCollectionModel) wrapper.wrap( Iterables.map( new Function<Property<?>, Object>() { @Override public Object map( Property<?> objectProperty ) { try { return wrapper.wrap( objectProperty.get() ); } catch( TemplateModelException e ) { throw new IllegalStateException( e ); } } }, Qi4j.FUNCTION_COMPOSITE_INSTANCE_OF.map( composite ).state().properties() ).iterator() ); }
private String getCompositeName( Composite composite ) { return first( Qi4j.FUNCTION_DESCRIPTOR_FOR.map( composite ).types()).getName(); } }