Interface BeanWrapper<T>

    • Method Detail

      • getBean

        @NonNull
        T getBean()
        Returns:
        The bean;
      • getPropertyNames

        @NonNull
        default java.lang.String[] getPropertyNames()
        The property names.
        Returns:
        The property names
      • getBeanProperties

        @NonNull
        default java.util.Collection<BeanProperty<T,​java.lang.Object>> getBeanProperties()
        The properties.
        Returns:
        The properties
      • getRequiredProperty

        @NonNull
        default <P> P getRequiredProperty​(@NonNull
                                          java.lang.String name,
                                          @NonNull
                                          java.lang.Class<P> type)
        Get the property value of the given type or throw an exception if it is unobtainable.
        Type Parameters:
        P - The property generic type
        Parameters:
        name - The name
        type - The type
        Returns:
        The property value
        Throws:
        IntrospectionException - if no property exists
        ConversionErrorException - if the property cannot be converted to the given type
      • getRequiredProperty

        default <P> P getRequiredProperty​(@NonNull
                                          java.lang.String name,
                                          @NonNull
                                          Argument<P> argument)
        Get the property value of the given type or throw an exception if it is unobtainable.
        Type Parameters:
        P - The property generic type
        Parameters:
        name - The name
        argument - The argument type
        Returns:
        The property value
        Throws:
        IntrospectionException - if no property exists
        ConversionErrorException - if the property cannot be converted to the given type
      • getRequiredProperty

        @NonNull
        default <P> P getRequiredProperty​(@NonNull
                                          java.lang.String name,
                                          @NonNull
                                          ArgumentConversionContext<P> context)
        Get the property value of the given type or throw an exception if it is unobtainable.
        Type Parameters:
        P - The property generic type
        Parameters:
        name - The name
        context - The type
        Returns:
        The property value
        Throws:
        IntrospectionException - if no property exists
        ConversionErrorException - if the property cannot be converted to the given type
      • getProperty

        @NonNull
        default <P> java.util.Optional<P> getProperty​(@NonNull
                                                      java.lang.String name,
                                                      @NonNull
                                                      java.lang.Class<P> type)
        Get the property of the given name and type.
        Type Parameters:
        P - The required generic type
        Parameters:
        name - The name
        type - The required type
        Returns:
        The property if found and can be converted to the given type
      • getProperty

        default <P> java.util.Optional<P> getProperty​(@NonNull
                                                      java.lang.String name,
                                                      Argument<P> type)
        Get the property of the given name and type.
        Type Parameters:
        P - The required generic type
        Parameters:
        name - The name
        type - The required type
        Returns:
        The property if found and can be converted to the given type
      • getProperty

        default <P> java.util.Optional<P> getProperty​(@NonNull
                                                      java.lang.String name,
                                                      ArgumentConversionContext<P> context)
        Get the property of the given name and type.
        Type Parameters:
        P - The required generic type
        Parameters:
        name - The name
        context - The conversion context
        Returns:
        The property if found and can be converted to the given type
      • setProperty

        default BeanWrapper<T> setProperty​(@NonNull
                                           java.lang.String name,
                                           @Nullable
                                           java.lang.Object value)
        Sets a property of the given name to the given value.
        Parameters:
        name - The name
        value - The value
        Returns:
        This wrapper
        Throws:
        ConversionErrorException - if the value cannot be converted to the underlying property type.
      • getWrapper

        @NonNull
        static <T2> BeanWrapper<T2> getWrapper​(@NonNull
                                               T2 bean)
        Obtain a bean wrapper for the given bean.
        Type Parameters:
        T2 - The bean type
        Parameters:
        bean - The bean
        Returns:
        The wrapper
        Throws:
        IntrospectionException - If the wrapper cannot be created
      • findWrapper

        @NonNull
        static <T2> java.util.Optional<BeanWrapper<T2>> findWrapper​(@NonNull
                                                                    T2 bean)
        Obtain a bean wrapper for the given bean.
        Type Parameters:
        T2 - The bean type
        Parameters:
        bean - The bean
        Returns:
        The wrapper
        Throws:
        IntrospectionException - If the wrapper cannot be created
      • findWrapper

        @NonNull
        static <T2> java.util.Optional<BeanWrapper<T2>> findWrapper​(java.lang.Class<T2> type,
                                                                    @NonNull
                                                                    T2 bean)
        Obtain a bean wrapper for the given bean.
        Type Parameters:
        T2 - The bean type
        Parameters:
        type - the type
        bean - The bean
        Returns:
        The wrapper
        Throws:
        IntrospectionException - If the wrapper cannot be created
      • getWrapper

        @NonNull
        static <T2> BeanWrapper<T2> getWrapper​(java.lang.Class<T2> type,
                                               @NonNull
                                               T2 bean)
        Obtain a bean wrapper for the given bean.
        Type Parameters:
        T2 - The bean type
        Parameters:
        type - the type
        bean - The bean
        Returns:
        The wrapper
        Throws:
        IntrospectionException - If the wrapper cannot be created