On 2017-08-23 13:39, Chetan Mehrotra wrote:
Below is one possible sketch of the proposed api. We introduce a new
AdaptableBinary which allows adapting a Binary to some other form.

API
===

public interface AdaptableBinary {

     /**
      * Adapts the binary to another type
      *
      * @param <AdapterType> The generic type to which this binary is adapted
      *            to
      * @param type The Class object of the target type
      * @return The adapter target or <code>null</code> if the binary cannot
      *         adapt to the requested type
      */
     <AdapterType> AdapterType adaptTo(Class<AdapterType> type);
}

Can we make that more generic, not relying on Binary?

Usage
=====

Binary binProp = node.getProperty("jcr:data").getBinary();

//Check if Binary is of type AdaptableBinary
if (binProp instanceof AdaptableBinary){
     AdaptableBinary adaptableBinary = (AdaptableBinary) binProp;
     SignedBinary url = adaptableBinary.adaptTo(SignedBinary.class);
}

Where SignedBinary is one of the supported adaptables.

public interface SignedBinary {

     URL getUrl(int ttl, TimeUnit unit)
}

Use URI, not URL.

...

Best regards, Julian

Reply via email to