Skip to content

Commit 68eda09

Browse files
gselzerctrueden
authored andcommitted
Add more javadoc
Also, changed the line endings in OpInstance from Windows to Linux.
1 parent c40a4f1 commit 68eda09

File tree

3 files changed

+72
-64
lines changed

3 files changed

+72
-64
lines changed

scijava/scijava-ops-api/src/main/java/org/scijava/ops/api/InfoChain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* A data structure wrangling a hierarchy of {@link OpInfo}s, created for every
12-
* Op match and called upon to instantiate any number of Op instances.
12+
* Op match and called upon to instantiate any number of {@link OpInstance}s.
1313
*
1414
* This {@link InfoChain} contains:
1515
* <ol>
Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,66 @@
1-
2-
package org.scijava.ops.api;
3-
4-
import java.lang.reflect.Type;
5-
import java.util.Objects;
6-
7-
import org.scijava.types.GenericTyped;
8-
9-
/**
10-
* An instance of an {@link OpInfo}
11-
*
12-
* @author Gabriel Selzer
13-
*/
14-
public class OpInstance<T> implements GenericTyped {
15-
16-
private final T op;
17-
private final InfoChain info;
18-
private final Type reifiedType;
19-
20-
public OpInstance(final T op, final InfoChain backingInfo,
21-
final Type reifiedType)
22-
{
23-
this.op = op;
24-
this.info = backingInfo;
25-
this.reifiedType = reifiedType;
26-
}
27-
28-
public static <T> OpInstance<T> of(T op, InfoChain backingInfo,
29-
final Type reifiedType)
30-
{
31-
return new OpInstance<>(op, backingInfo, reifiedType);
32-
}
33-
34-
public T op() {
35-
return op;
36-
}
37-
38-
public InfoChain infoChain() {
39-
return info;
40-
}
41-
42-
@Override
43-
public boolean equals(Object that) {
44-
if (!(that instanceof OpInstance)) return false;
45-
OpInstance<?> thatInstance = (OpInstance<?>) that;
46-
boolean infosEqual = infoChain().equals(thatInstance.infoChain());
47-
boolean objectsEqual = op().equals(thatInstance.op());
48-
boolean typesEqual = getType().equals(thatInstance.getType());
49-
return infosEqual && objectsEqual && typesEqual;
50-
}
51-
52-
@Override
53-
public int hashCode() {
54-
return Objects.hash(infoChain(), op(), getType());
55-
}
56-
57-
@Override
58-
public Type getType() {
59-
return reifiedType;
60-
}
61-
62-
}
1+
2+
package org.scijava.ops.api;
3+
4+
import java.lang.reflect.Type;
5+
import java.util.Objects;
6+
7+
import org.scijava.types.GenericTyped;
8+
9+
/**
10+
* An instance of an {@link OpInfo}. They can be constructed directly, but are
11+
* easily generated from {@link InfoChain}s.
12+
* <p>
13+
* Each {@link OpInstance} has an Op and its corresponding {@link OpInfo}.
14+
* </p>
15+
*
16+
* @author Gabriel Selzer
17+
*/
18+
public class OpInstance<T> implements GenericTyped {
19+
20+
private final T op;
21+
private final InfoChain info;
22+
private final Type reifiedType;
23+
24+
public OpInstance(final T op, final InfoChain backingInfo,
25+
final Type reifiedType)
26+
{
27+
this.op = op;
28+
this.info = backingInfo;
29+
this.reifiedType = reifiedType;
30+
}
31+
32+
public static <T> OpInstance<T> of(T op, InfoChain backingInfo,
33+
final Type reifiedType)
34+
{
35+
return new OpInstance<>(op, backingInfo, reifiedType);
36+
}
37+
38+
public T op() {
39+
return op;
40+
}
41+
42+
public InfoChain infoChain() {
43+
return info;
44+
}
45+
46+
@Override
47+
public boolean equals(Object that) {
48+
if (!(that instanceof OpInstance)) return false;
49+
OpInstance<?> thatInstance = (OpInstance<?>) that;
50+
boolean infosEqual = infoChain().equals(thatInstance.infoChain());
51+
boolean objectsEqual = op().equals(thatInstance.op());
52+
boolean typesEqual = getType().equals(thatInstance.getType());
53+
return infosEqual && objectsEqual && typesEqual;
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return Objects.hash(infoChain(), op(), getType());
59+
}
60+
61+
@Override
62+
public Type getType() {
63+
return reifiedType;
64+
}
65+
66+
}

scijava/scijava-ops-api/src/main/java/org/scijava/ops/api/RichOp.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
/**
99
* An {@link OpInstance} with state (i.e. an {@link OpMetadata})
10+
* <p>
11+
* Each {@link RichOp} has <b>one</b> {@link OpInstance}, and <b>one</b>
12+
* {@link OpMetadata}.
13+
* </p>
1014
*
1115
* @author Gabriel Selzer
12-
* @param <T>
16+
* @param <T> the functional {@link Type} of the wrapped Op
1317
*/
1418
public interface RichOp<T> extends GenericTyped {
1519

0 commit comments

Comments
 (0)