VirtualPropertyResolver extends now StrLookup to avoid an additonal wrapper in RSQLUtility
Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
@@ -196,8 +196,8 @@ public final class RSQLUtility {
|
|||||||
this.root = root;
|
this.root = root;
|
||||||
this.cb = cb;
|
this.cb = cb;
|
||||||
this.enumType = enumType;
|
this.enumType = enumType;
|
||||||
this.substitutor = (virtualPropertyLookup != null)
|
this.substitutor = (virtualPropertyLookup != null && virtualPropertyLookup instanceof StrLookup)
|
||||||
? new StrSubstitutor(new StrLookupAdapter(virtualPropertyLookup), StrSubstitutor.DEFAULT_PREFIX,
|
? new StrSubstitutor((StrLookup)virtualPropertyLookup, StrSubstitutor.DEFAULT_PREFIX,
|
||||||
StrSubstitutor.DEFAULT_SUFFIX, StrSubstitutor.DEFAULT_ESCAPE)
|
StrSubstitutor.DEFAULT_SUFFIX, StrSubstitutor.DEFAULT_ESCAPE)
|
||||||
: null;
|
: null;
|
||||||
simpleTypeConverter = new SimpleTypeConverter();
|
simpleTypeConverter = new SimpleTypeConverter();
|
||||||
@@ -592,27 +592,4 @@ public final class RSQLUtility {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapts the <code>VirtualPropertyLookup</code> to <code>StrLookup</code>.
|
|
||||||
*/
|
|
||||||
static final class StrLookupAdapter extends StrLookup<String> {
|
|
||||||
|
|
||||||
private VirtualPropertyLookup virtualPropertyLookup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param virtualPropertyLookup
|
|
||||||
* the lookup to adapt.
|
|
||||||
*/
|
|
||||||
StrLookupAdapter(VirtualPropertyLookup virtualPropertyLookup) {
|
|
||||||
this.virtualPropertyLookup = virtualPropertyLookup;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String lookup(String key) {
|
|
||||||
return virtualPropertyLookup.lookup(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
|||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.text.StrLookup;
|
||||||
import org.eclipse.hawkbit.repository.jpa.TimestampCalculator;
|
import org.eclipse.hawkbit.repository.jpa.TimestampCalculator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -41,7 +42,7 @@ import org.springframework.stereotype.Component;
|
|||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class VirtualPropertyResolver implements VirtualPropertyLookup {
|
public class VirtualPropertyResolver extends StrLookup<String> implements VirtualPropertyLookup {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TimestampCalculator timestampCalculator;
|
private TimestampCalculator timestampCalculator;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class VirtualPropertyResolverTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.substitutor = new StrSubstitutor(new RSQLUtility.StrLookupAdapter(resolverUnderTest),
|
this.substitutor = new StrSubstitutor(resolverUnderTest,
|
||||||
StrSubstitutor.DEFAULT_PREFIX,
|
StrSubstitutor.DEFAULT_PREFIX,
|
||||||
StrSubstitutor.DEFAULT_SUFFIX, StrSubstitutor.DEFAULT_ESCAPE);
|
StrSubstitutor.DEFAULT_SUFFIX, StrSubstitutor.DEFAULT_ESCAPE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user