Package com.liferay.adaptive.media
Class AMAttribute<T,V>
java.lang.Object
com.liferay.adaptive.media.AMAttribute<T,V>
Represents a characteristic of an
AdaptiveMedia instance (e.g., its
width, size, etc.). Instances are annotated by a processor type and by the
attribute value type. The processor type restriction prevents AdaptiveMedia users from requesting unsupported attributes (i.e., the set of
available attributes is checked at compile time). The attribute value type
annotation reduces (or avoids completely) the need to cast retrieved
attribute values.-
Constructor Summary
ConstructorsConstructorDescriptionAMAttribute(String name, Function<String, V> converterFunction, AMDistanceComparator<V> amDistanceComparator) Creates a new attribute. -
Method Summary
Modifier and TypeMethodDescriptionlongCompares the two arguments for order.Returns the value converted to the correct type.longReturns the distance between the two values.static Map<String, AMAttribute<?, ?>> Returns a string-attribute map containing the available name-attribute pairs.static <S> AMAttribute<S, String> Returns a generic attribute representing the configuration UUID used to generate the media.static <S> AMAttribute<S, Long> Returns a generic attribute representing the length of the media's content.static <S> AMAttribute<S, String> Returns a generic attribute representing the media's content type.static <S> AMAttribute<S, String> Returns a generic attribute representing the media's file name (if any).getName()Returns thisAdaptiveMediainstance's globally unique name.
-
Constructor Details
-
AMAttribute
public AMAttribute(String name, Function<String, V> converterFunction, AMDistanceComparator<V> amDistanceComparator) Creates a new attribute. All attributes live in the same global namespace.- Parameters:
name- a value that uniquely identifies the attributeamDistanceComparator- the comparator to order the two arguments based on the distance between their values; it should return a value betweenLong.MIN_VALUEandLong.MAX_VALUE
-
-
Method Details
-
getAllowedAMAttributes
Returns a string-attribute map containing the available name-attribute pairs.- Returns:
- the list of available attributes
-
getConfigurationUuidAMAttribute
Returns a generic attribute representing the configuration UUID used to generate the media. This attribute can be used with any kind of media.- Returns:
- the configuration UUID
-
getContentLengthAMAttribute
Returns a generic attribute representing the length of the media's content. This attribute can be used with any kind of media.- Returns:
- the content length attribute
-
getContentTypeAMAttribute
Returns a generic attribute representing the media's content type. This attribute can be used with any kind of media.- Returns:
- the content type attribute
-
getFileNameAMAttribute
Returns a generic attribute representing the media's file name (if any). This attribute can be used with any kind of media.- Returns:
- the file name attribute
-
compare
Compares the two arguments for order.- Parameters:
value1- the first value to comparevalue2- the second value to compare- Returns:
- a negative long, zero, or positive long, depending on whether the first argument is less than, equal to, or greater than the second argument
-
convert
Returns the value converted to the correct type.- Parameters:
value- the value to convert- Returns:
- the value converted to the correct type
-
distance
Returns the distance between the two values.- Parameters:
value1- the first valuevalue2- the second value- Returns:
- a value between 0 and
Long.MAX_VALUE, representing the distance between the two values
-
getName
Returns thisAdaptiveMediainstance's globally unique name.- Returns:
- the attribute's name
-