Relation.java
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.util.callbacks.Option
* javax.jcr.Node
* javax.jcr.RepositoryException
* org.apache.sling.api.adapter.Adaptable
*/
package com.adobe.cq.dam.s7imaging.impl.jcr.adapters;
import com.adobe.cq.dam.s7imaging.impl.catalog.JcrUtil;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.JcrProps;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.PropExtractor;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.PropKey;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.StandardExtractors;
import com.scene7.is.util.callbacks.Option;
import java.util.Iterator;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.sling.api.adapter.Adaptable;
public class Relation {
public final String path;
public final JcrProps props;
private static final String SLING_RESOURCE = "sling:resource";
private static final PropKey<Option<String>> SlingResource = PropKey.optional("sling:resource", StandardExtractors.toString);
public static Option<Relation> relation(Node node) throws RepositoryException {
JcrProps props = JcrProps.jcrProps(node);
Iterator i$ = props.get(SlingResource).iterator();
if (i$.hasNext()) {
String path = (String)i$.next();
return Option.some((Object)new Relation(path, props));
}
return Option.none();
}
public static Option<Relation> relation(Adaptable node) throws RepositoryException {
Iterator i$ = JcrUtil.adaptTo(Node.class, node).iterator();
if (i$.hasNext()) {
Node n = (Node)i$.next();
return Relation.relation(n);
}
return Option.none();
}
public static Relation relation(String path) {
return new Relation(path, JcrProps.emptyJcrProps());
}
private Relation(String path, JcrProps props) {
this.path = path;
this.props = props;
}
}