Result
- any type this implementation wants to use as a resultpublic interface BinaryForSourceQueryImplementation2<Result> extends BinaryForSourceQueryImplementation
BinaryForSourceQueryImplementation
, this query also allows one
to specify whether binaries are preferred
- e.g. copied instead of obtaining them by compiling the sources.
The typical implementation of the query looks like:
@ServiceProvider
(service =BinaryForSourceQueryImplementation
.class) public final static class SampleQuery implementsBinaryForSourceQueryImplementation2
<SampleQuery.PrivateData> { public SampleQuery() { } @Override
public PrivateData findBinaryRoots2(URL
sourceRoot) { finalFileObject
fo =URLMapper
.findFileObject(sourceRoot); assertNotNull("FileObject found", fo); return new PrivateData(sourceRoot, fo); } @Override
publicURL
[] computeRoots(PrivateData result) { return newURL
[] { result.url }; } @Override
public boolean computePreferBinaries(PrivateData result) { return true; } @Override
public void computeChangeListener(PrivateData data, boolean add,ChangeListener
l) { if (add) { assertNull("No listener yet", data.listener); data.listener = l; } else { assertEquals("Removing", data.listener, l); data.listener = null; } } public static final class PrivateData { finalURL
url; finalFileObject
fo;ChangeListener
listener; PrivateData(URL
url,FileObject
fo) { this.fo = fo; this.url = url; } @Override
public int hashCode() { int hash = 7; hash = 97 * hash +Objects
.hashCode(this.url); return hash; } @Override
public boolean equals(Object
obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final PrivateData other = (PrivateData) obj; returnObjects
.equals(this.url, other.url); } } }
BinaryForSourceQuery
,
SourceForBinaryQuery
,
BinaryForSourceQueryImplementation
,
SourceForBinaryQueryImplementation
Modifier and Type | Method and Description |
---|---|
void |
computeChangeListener(Result result,
boolean add,
ChangeListener l)
|
boolean |
computePreferBinaries(Result result)
Implementation of
BinaryForSourceQuery.Result2.preferBinaries() . |
URL[] |
computeRoots(Result result)
Implementation of
BinaryForSourceQuery.Result.getRoots() . |
default BinaryForSourceQuery.Result2 |
findBinaryRoots(URL sourceRoot)
Default
implementation of
BinaryForSourceQueryImplementation.findBinaryRoots(java.net.URL) . |
Result |
findBinaryRoots2(URL sourceRoot)
Returns the binary root result for a given source root.
|
default BinaryForSourceQuery.Result2 findBinaryRoots(URL sourceRoot)
BinaryForSourceQueryImplementation.findBinaryRoots(java.net.URL)
.
Calls BinaryForSourceQueryImplementation2.findBinaryRoots2(java.net.URL)
and if the method returns non-null
value, then it creates instances of BinaryForSourceQuery.Result2
and returns
it. Otherwise it returns null
.
Override BinaryForSourceQueryImplementation2.findBinaryRoots2(java.net.URL)
, not this method!
findBinaryRoots
in interface BinaryForSourceQueryImplementation
sourceRoot
- null
result if this query has an answer for the provided sourceRoot
Result findBinaryRoots2(URL sourceRoot)
The returned Result
must be consistent. It means that for
repeated calling of this method with the same recognized root the method has to
return the equal
result with the
same Object.hashCode()
. The implementation of the
BinaryForSourceQueryImplementation2.findBinaryRoots(java.net.URL)
method makes sure the same
BinaryForSourceQuery.Result2
instance is returned for two
equal Result
objects.
sourceRoot
- the source path rootnull
if the sourceRoot is not recognized, or any object
to feed into BinaryForSourceQueryImplementation2.computeRoots(java.lang.Object)
& co. methods
any time laterURL[] computeRoots(Result result)
BinaryForSourceQuery.Result.getRoots()
.result
- object created by BinaryForSourceQueryImplementation2.findBinaryRoots2(java.net.URL)
methodBinaryForSourceQuery.Result.getRoots()
boolean computePreferBinaries(Result result)
BinaryForSourceQuery.Result2.preferBinaries()
.result
- object created by BinaryForSourceQueryImplementation2.findBinaryRoots2(java.net.URL)
methodBinaryForSourceQuery.Result2.preferBinaries()
void computeChangeListener(Result result, boolean add, ChangeListener l)
result
- object created by BinaryForSourceQueryImplementation2.findBinaryRoots2(java.net.URL)
methodl
- the listener to operate onadd
- add or remove the listener?