Class Properties


  • public final class Properties
    extends Object
    Utility functions for dealing with single properties and property streams.
    • Method Detail

      • getProperties

        public static com.entwinemedia.fn.Stream<Property> getProperties​(AResult result)
        Extract all properties contained in a result. They'll appear in the order of the returned records.
      • byPropertyName

        public static com.entwinemedia.fn.Pred<Property> byPropertyName​(String propertyName)
        Create a predicate to query a property by its name.
        See Also:
        PropertyId.getName()
      • byFqnName

        public static com.entwinemedia.fn.Pred<Property> byFqnName​(PropertyName name)
        Create a predicate to query a property by its full qualified name which is the tuple of namespace and name.
        See Also:
        PropertyId.getFqn()
      • setProperty

        public static boolean setProperty​(AssetManager am,
                                          String mpId,
                                          String namespace,
                                          String propertyName,
                                          String value)
        Deprecated.
        make use of a PropertySchema instead of creating property IDs manually
        Set a string property on a media package.
      • setProperty

        public static boolean setProperty​(AssetManager am,
                                          String mpId,
                                          String namespace,
                                          String propertyName,
                                          Date value)
        Deprecated.
        make use of a PropertySchema instead of creating property IDs manually
        Set a date property on a media package.
      • setProperty

        public static boolean setProperty​(AssetManager am,
                                          String mpId,
                                          String namespace,
                                          String propertyName,
                                          Long value)
        Deprecated.
        make use of a PropertySchema instead of creating property IDs manually
        Set a long property on a media package.
      • setProperty

        public static boolean setProperty​(AssetManager am,
                                          String mpId,
                                          String namespace,
                                          String propertyName,
                                          boolean value)
        Deprecated.
        make use of a PropertySchema instead of creating property IDs manually
        Set a boolean property on a media package.
      • setProperty

        public static boolean setProperty​(AssetManager am,
                                          String mpId,
                                          String namespace,
                                          String propertyName,
                                          Value value)
        Deprecated.
        make use of a PropertySchema instead of creating property IDs manually
        Set a property on a media package.
      • getValue

        public static <A> com.entwinemedia.fn.Fn<Property,​A> getValue​(Value.ValueType<A> ev)
        Create a function to get a value from a property.
        Parameters:
        ev - the expected value type
      • getValue

        public static <A> com.entwinemedia.fn.StreamFold<Property,​A> getValue​(Value.ValueType<A> ev,
                                                                                    String propertyName)
        Create a stream fold to find the first property whose name matches the given one and extract its value.
        Parameters:
        ev - the expected value type
        propertyName - the name of the property
        Throws:
        RuntimeException - if the property cannot be found or its type does not match
      • getValue

        public static <A> com.entwinemedia.fn.StreamFold<Property,​A> getValue​(Value.ValueType<A> ev,
                                                                                    PropertyName name)
        Create a stream fold to find the first property whose full qualified name matches the given one and extract its value.
        Parameters:
        ev - the expected value type
        name - the full qualified name of the property
        Throws:
        RuntimeException - if the property cannot be found or its type does not match
      • getValueOpt

        public static <A> com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<A>> getValueOpt​(Value.ValueType<A> ev,
                                                                                                                     String propertyName)
        Create a stream fold to find the first property whose name matches the given one and extract its value, wrapped in an Opt.
        Parameters:
        ev - the expected value type
        propertyName - the name of the property
      • getValueOpt

        public static <A> com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<A>> getValueOpt​(Value.ValueType<A> ev,
                                                                                                                     PropertyName name)
        Create a stream fold to find the first property whose full qualified name matches the given one and extract their values, wrapped in an Opt.
        Parameters:
        ev - the expected value type
        name - the full qualified name of the property
      • get

        public static com.entwinemedia.fn.Fn<com.entwinemedia.fn.data.Opt<Property>,​Property> get​(String propertyName)
        Apply #get() to the given Opt or throw a RuntimeException if none. Use propertyName for the exception message.
      • get

        public static com.entwinemedia.fn.Fn<com.entwinemedia.fn.data.Opt<Property>,​Property> get​(PropertyName name)
        Apply #get() to the given Opt or throw a RuntimeException if none. Use name for the exception message.
      • mkProperty

        public static <A> Property mkProperty​(PropertyField<A> f,
                                              org.opencastproject.mediapackage.MediaPackage mp,
                                              A value)
        Create a property.
      • getBoolean

        public static com.entwinemedia.fn.StreamFold<Property,​Boolean> getBoolean​(String propertyName)
        Get a boolean value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a boolean
      • getBoolean

        public static com.entwinemedia.fn.StreamFold<Property,​Boolean> getBoolean​(PropertyName name)
        Get a boolean value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a boolean
      • getString

        public static com.entwinemedia.fn.StreamFold<Property,​String> getString​(String propertyName)
        Get a string value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a string
      • getString

        public static com.entwinemedia.fn.StreamFold<Property,​String> getString​(PropertyName name)
        Get a string value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a string
      • getStrings

        public static com.entwinemedia.fn.StreamOp<Property,​String> getStrings​(String propertyName)
        Get string values from all properties.
        Throws:
        RuntimeException - if at least one property is not a string
      • getStrings

        public static com.entwinemedia.fn.StreamOp<Property,​String> getStrings​(PropertyName name)
        Get string values from all properties.
        Throws:
        RuntimeException - if at least one property is not a string
      • getDate

        public static com.entwinemedia.fn.StreamFold<Property,​Date> getDate​(String propertyName)
        Get a date value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a date
      • getDate

        public static com.entwinemedia.fn.StreamFold<Property,​Date> getDate​(PropertyName name)
        Get a date value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a date
      • getLong

        public static com.entwinemedia.fn.StreamFold<Property,​Long> getLong​(String propertyName)
        Get a long value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a long
      • getLong

        public static com.entwinemedia.fn.StreamFold<Property,​Long> getLong​(PropertyName name)
        Get a long value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property does not exist or if the property is not a long
      • getStringOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<String>> getStringOpt​(String propertyName)
        Get a string value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a string
      • getStringOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<String>> getStringOpt​(PropertyName name)
        Get a string value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a string
      • getDateOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<Date>> getDateOpt​(String propertyName)
        Get a date value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a date
      • getDateOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<Date>> getDateOpt​(PropertyName name)
        Get a date value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a date
      • getLongOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<Long>> getLongOpt​(String propertyName)
        Get a long value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a long
      • getLongOpt

        public static com.entwinemedia.fn.StreamFold<Property,​com.entwinemedia.fn.data.Opt<Long>> getLongOpt​(PropertyName name)
        Get a long value. Uses the first property with the given name.
        Throws:
        RuntimeException - if the property is not a long