RequiredPropKey.java
1.36 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.util.callbacks.Option
* javax.jcr.Property
* javax.jcr.RepositoryException
*/
package com.adobe.cq.dam.s7imaging.impl.jcr.props;
import com.adobe.cq.dam.s7imaging.impl.jcr.props.PropKey;
import com.scene7.is.util.callbacks.Option;
import java.util.Iterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
class RequiredPropKey<T>
extends PropKey<T> {
private final PropKey<Option<T>> delegate;
private Option<T> defaultValue;
static <T> PropKey<T> requiredPropKey(PropKey<Option<T>> delegate, Option<T> defaultValue) {
return new RequiredPropKey<T>(delegate, defaultValue);
}
@Override
T extractValue(Option<Property> value) throws RepositoryException {
Iterator i$ = this.delegate.extractValue(value).iterator();
if (i$.hasNext()) {
Object v = i$.next();
return (T)v;
}
i$ = this.defaultValue.iterator();
if (i$.hasNext()) {
Object v = i$.next();
return (T)v;
}
throw new RepositoryException("Required property " + this.name);
}
private RequiredPropKey(PropKey<Option<T>> delegate, Option<T> defaultValue) {
super(delegate.name);
this.delegate = delegate;
this.defaultValue = defaultValue;
}
}