Class AMAttribute<T,V>

java.lang.Object
com.liferay.adaptive.media.AMAttribute<T,V>

public final class AMAttribute<T,V> extends Object
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 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 attribute
      amDistanceComparator - the comparator to order the two arguments based on the distance between their values; it should return a value between Long.MIN_VALUE and Long.MAX_VALUE
  • Method Details

    • getAllowedAMAttributes

      public static Map<String,AMAttribute<?,?>> getAllowedAMAttributes()
      Returns a string-attribute map containing the available name-attribute pairs.
      Returns:
      the list of available attributes
    • getConfigurationUuidAMAttribute

      public static <S> AMAttribute<S,String> 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

      public static <S> AMAttribute<S,Long> 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

      public static <S> AMAttribute<S,String> 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

      public static <S> AMAttribute<S,String> 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

      public long compare(V value1, V value2)
      Compares the two arguments for order.
      Parameters:
      value1 - the first value to compare
      value2 - 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

      public V convert(String value)
      Returns the value converted to the correct type.
      Parameters:
      value - the value to convert
      Returns:
      the value converted to the correct type
    • distance

      public long distance(V value1, V value2)
      Returns the distance between the two values.
      Parameters:
      value1 - the first value
      value2 - the second value
      Returns:
      a value between 0 and Long.MAX_VALUE, representing the distance between the two values
    • getName

      public String getName()
      Returns this AdaptiveMedia instance's globally unique name.
      Returns:
      the attribute's name